Thinkphp does not select to upload files
File Upload
Class UploadAction extends Action {
Function index (){
$ This-> display ();
}
Public function upload (){
Import ('org. NET. uploadfile ');
$ Upload = new UploadFile ();
$ Upload-> maxSize = 200000;
$ Upload-> allowExts = array ('jpg ', 'GIF', 'PNG', 'jpeg ');
$ Upload-> saveRule = uniqid;
$ Upload-> savePath = './Public/Uploads /';
$ Upload-> thumb = true;
$ Upload-> thumbMaxWidth = 120;
$ Upload-> thumbMaxHeight = 140;
$ Upload-> thumbRemoveOrigin = false;
$ Upload-> thumbPath = './Public/Thumb /';
If ($ _ FILES ['myfile'] ['error']> 0 ){
Echo 'error ';
} Else {
Echo "success ";
}
If ($ upload-> upload ()){
$ Info = $ upload-> getUploadFileInfo ();
Echo $ Info;
} Else {
Echo $ _ FILES ['myfile'] ['error'];
$ This-> Error ($ upload-> getErrorMsg ());
}
}
// File Upload
}
It always shows that you have not selected to upload files. do you know what is going on?
Reply to discussion (solution)
What are the specific prompts or error messages?
Operation failed! File Not Selected
The page will automatically jump in 3 seconds. if you do not want to wait, click here to jump
The success word can be output above.
Are you sure you want to write your html code? Is your phpini enabled?
Mulitypart-form/data
It should be: multipart/form-data
How can I solve this problem? How come no one answered?
Add enctype = "multipart/form-data" to form"