我正在尝试上传文件,文件名带括号,例如sample(1).jpg,sample(2).jpg它会抛出错误给定
Error: can't upload.The filetype you are attempting to upload is not allowed.
仍然,我的配置如下:
$config['upload_path'] = './images/project_docs/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|pptx|docx|xlsx';
$config['max_size'] = '2000000';
$config['remove_spaces'] = true;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if($this->upload->do_upload('docs')){
echo $fileName = $this->upload->data('file_name'); exit();
}else{
$errors = array('e'=>$this->upload->display_errors("can't upload."));
print_r($errors);exit();
}
答案 0 :(得分:0)
归因于$config['remove_spaces']
,因为默认情况下删除空格是真的,文件名中的任何空格都将转换为下划线。
要解决此问题,请使用$config['remove_spaces'] = FALSE;