我想将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”