Htinkphp uploads an image and reports "illegal image file" thinkphp uploads an image
Yes locally, but not on the server, but the txt file is successfully uploaded, which is definitely not a problem with directory permissions. Solution
// Save the attachment to the specified path
$ Upload = new UploadFile (); // instantiate the upload class
$ Upload-> maxSize = 2*1024*1024; // sets the attachment upload size.
$ Upload-> allowExts = explode (',', 'jpg, gif, png, jpeg, txt, doc, docx, wps, xls, et, zip, tar, rar, gz, 7z'); // sets the attachment Upload type.
$ Upload-> savePath = 'tpl/Public/Uploads/task_description/'; // Set the attachment 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 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;
}
Reply to discussion (solution)
Since the server can be used locally, it must have been a restriction on the server.
Try uploading a small image.
Since the server can be used locally, it must have been a restriction on the server.
Try uploading a small image.
The uploaded image is very small. I don't know why.
Try another few images. There may be image problems, and there may be dozens of utf8 files which are the best to check your php file encoding. encoding problems may also cause Upload failure.
Conclusion: haha
Because thinkph has a problem in determining the image type, it does not take into account the conversion of the image type by the browser. for example, on ie, the uploaded jpg file is image/pjpeg. So ......
How can this problem be solved?