我试图上传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 :(得分:0)
只需添加*
Ex:$config['allowed_types'] = '*';
并删除此$config['allowed_types'] = 'rar|zip|gif|jpg|png|jpeg';