简体   繁体   English

如何在codeigniter中上传zip文件?

[英]How to upload a zip files in codeigniter?

I'm trying to upload a zip files but I'm getting some error and I want to display the images inside of it. 我正在尝试上传一个zip文件,但出现了一些错误,我想在其中显示图像。 This is my code this is my code: 这是我的代码,这是我的代码:

Controller 控制者

$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');

just add * for Ex : $config['allowed_types'] = '*'; 只需为Ex添加*: $config['allowed_types'] = '*'; and remove this $config['allowed_types'] = 'rar|zip|gif|jpg|png|jpeg'; 并删除此$config['allowed_types'] = 'rar|zip|gif|jpg|png|jpeg';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM