htinkphp upload image "Illegal image file" solution

Source: Internet
Author: User
htinkphp upload image "Illegal image file"
Local can, not on the server, but the upload TXT file is successful, is certainly not a directory permissions problem. Solving



Save attachments below the specified path
$upload = new UploadFile ();//instantiation of upload class
$upload->maxsize = 2*1024*1024;//Set attachment upload size
$upload->allowexts = Explode (', ', ' jpg,gif,png,jpeg,txt,doc,docx,wps,xls,et,zip,tar,rar,gz,7z ');//Set attachment upload type
$upload->savepath = ' tpl/public/uploads/task_description/';//Set Attachments upload Directory

Modify the name of the uploaded file
$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 ()) {//Upload error error message
echo $upload->geterrormsg ();
$this->error ($upload->geterrormsg ());
}else{
$info = $upload->getuploadfileinfo ();
Save the data to the database
$data [' Wlfileurl ']= $info [0][' Savepath ']. $new _name;
} thinkphp? picture upload?

Share to:


------Solution--------------------
Since the local can, the server does not, that must be the server there is a limit.
You pass a small picture and try it.
------Solution--------------------
A few more pictures to try, there may be a picture problem, there are dozens of to see your php file encoding best UTF8, there may be coding problems can also cause the inability to upload
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.