我想将 2 个文件上传到不同的路径,但在第一个路径它可以正常工作,但是当它使用下一个路径时,它的错误是“不允许您尝试上传的文件类型”。
模型
$this->load->model('blogmaintain_helper');
$data['cover_path'] = $this->blogmaintain_helper->upload_cover();
$data['file_path'] = $this->blogmaintain_helper->upload_file();
控制器
function upload_cover(){
$config_cover['upload_path'] = 'ftp://[server_path]/public_html/img/blog/';
$config_cover['allowed_types'] = 'gif|jpg|png|tif';
get_instance()->load->library('upload', $config_cover);
if($this->upload->do_upload('myFile'))
{
echo "Cover upload success";
return true;
}
else
{
echo $this->upload->display_errors();
}
}
function upload_file(){
$config_file['upload_path'] = 'ftp://[server_path]/public_html/document/blog/';
//$config['upload_path'] = 'document/blog/';
$config_file['allowed_types'] = 'doc|docx|pdf|txt|xls|xlsx|ppt|pptx';
get_instance()->load->library('upload', $config_file);
if($this->upload->do_upload('myDoc'))
{
echo "File upload success";
}
else
{
echo $this->upload->display_errors();
}
}
我可以将 myFile 上传到 img/blog,但是当它执行“upload_file”时,会出现“不允许您尝试上传的文件类型”的错误。
PS* myDoc 是“test.txt”,myFile 是“pic.jpg”