我正在使用 codeigniter 为我的博客创建文件上传功能。因为我接受两种格式的 zip|rar。
它给出错误,因为不允许您尝试上传的文件类型。. 如果将其更改为其他格式(如 image 或 txt ),它工作正常。
请找到代码片段
$config['upload_path'] = './public/';
$config['allowed_types'] = 'zip';
$config['max_size'] = '6000';
//$config['file_name'] = $authorName.$config['file_ext'];
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload()){
$data['serverMessage'] = "E75";
$data['uploadError'] = $this->upload->display_errors();
$data['message'] =$this->upload->display_errors();
}else{
$data['message'] ="Thanks you";
}
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
$this->load->view('guestpost', $data);