2016-07-26 108 views
0

我想上傳一個zip文件,但我得到一些錯誤,我想顯示它裏面的圖像。這是我的代碼,這是我的代碼:如何在codeigniter中上傳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'); 
+0

代碼粘貼文本不圖像。 – zajonc

+0

我編輯了我的帖子 – Holow

+0

粘貼錯誤。 – Tpojka

回答

0

只需添加* 防爆:$config['allowed_types'] = '*';和刪除此$config['allowed_types'] = 'rar|zip|gif|jpg|png|jpeg';

+0

我將它改爲*並且發生錯誤。我應該如何在我的視圖中調用它? – Holow