如何在codeigniter中上传zip文件?

时间:2016-07-26 05:56:13

标签: php codeigniter model-view-controller file-upload zip

我试图上传zip文件,但我收到了一些错误,我想在其中显示图片。这是我的代码,这是我的代码:

控制器

$config['upload_path'] = './img/header/';   
$config['allowed_types'] = 'rar|zip|gif|jpg|png|jpeg';
$config['max_size'] = '2048000';
$config['overwrite'] = TRUE;          

$this->load->library('upload', $config);

$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="alert alert-danger" role="alert">', '</div>');
$this->form_validation->set_rules('title', 'Name', 'trim|required');

if ($this->form_validation->run() == FALSE || !$this->upload->do_upload('userfile')) { 
    $this->load->view('plmar/admin/headContent');
} else {
    $content = array(
        'header_title' => $_POST['title'],
        'header_path' => $_POST['userfile'],
        'upload_data' => $this->upload->data()
    );

    $this->adminModel->addContent($content);
    redirect('Administrator/headContent');
}

$this->load->view('admin/footer');

1 个答案:

答案 0 :(得分:0)

只需添加* Ex:$config['allowed_types'] = '*';并删除此$config['allowed_types'] = 'rar|zip|gif|jpg|png|jpeg';