Home >Backend Development >PHP Tutorial > htinkphp上传图片报“非法图像文件”解决办法

htinkphp上传图片报“非法图像文件”解决办法

WBOY
WBOYOriginal
2016-06-13 12:37:422198browse

htinkphp上传图片报“非法图像文件”
本地可以,服务器上不行,可是上传txt文件又成功,肯定不是目录权限的问题。求解



//保存附件到指定路径下面
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 2*1024*1024;// 设置附件上传大小
$upload->allowExts = explode ( ',','jpg,gif,png,jpeg,txt,doc,docx,wps,xls,et,zip,tar,rar,gz,7z');// 设置附件上传类型
$upload->savePath = 'Tpl/Public/Uploads/task_description/';// 设置附件上传目录

//修改上传文件的名称
$file_name=$_FILES['taskfile']['name'];
$expand_name=explode(".",$file_name);
$new_name=date('YmdHis',time()).'.'.strtolower($expand_name[count($expand_name)-1]);

$_FILES["taskfile"]["name"]=$new_name;

if(!$upload->upload()) {// 上传错误提示错误信息
echo $upload->getErrorMsg();
//$this->error($upload->getErrorMsg());
}else{
$info = $upload->getUploadFileInfo();
//保存数据到数据库中
$data['wlFileUrl']=$info[0]['savepath'].$new_name;
}

thinkphp?图片上传?
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn