Thinkphp does not select to upload files

Source: Internet
Author: User
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"

Related Article

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.