CodeIgniter upload picture appears "You did don't select a file to upload" error resolution _php instance

Source: Internet
Author: User
Tags file upload codeigniter

CodeIgniter file Upload class is very easy to use, you can set specify the upload of a certain type of file and the size of the file specified. However, in the use of the process need to pay attention to a number of small problems, otherwise it will make you feel unprepared.

Many developers in the use of CodeIgniter upload upload class, always appear "You did not select a file to upload" error, from the code to see there is nothing wrong, this is how it?

1, the name of the file domain was modified

Method One:

For example, the name of the file field of the views file is modified to fileimg, and the name of the CI default file domain is UserFile, which is like: <input type= "file" Name= "UserFile" size= "." This can not be modified, otherwise you will not be able to find the upload file.

The principle is: $this->upload->do_upload () The default upload file table Single-name for UserFile.

Method Two:

In fact, there is a workaround if the file domain is a different name. Like what:

<input type= "File" Name= "Imgfile" size= "

Will

Copy Code code as follows:
$this->upload->do_upload ();

To

Copy Code code as follows:
$this->upload->do_upload (' imgfile ');

That's it!

2, Form form type

Form forms need to use Form_open_multipart, when the formation of HTML will add a property enctype= "Multipart/form-data", this is actually common sense, pay attention to the good.

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.