Codeigniter: Youdidnotselectafiletoupload error when uploading images _ php instance

Source: Internet
Author: User
This article mainly introduces the solution for "Youdidnotselectafiletoupload" when uploading images by Codeigniter. For more information, see the file upload class provided by Codeigniter, you can specify the file type to be uploaded and the file size to be specified. However, you need to pay attention to some minor issues during use. Otherwise, you will be caught off guard.

Many developers always encounter the "You did not select a file to upload" error when using the Codeigniter upload class. there is no error in the code. what is the problem?

1. the file domain name is modified.

Method 1:

For example, change the file domain name of the Views file to fileimg, and the default file domain name of CI is userfile, which is shown as follows:. This cannot be modified. Otherwise, the uploaded file cannot be found.

The principle is: $ this-> upload-> do_upload () by default, the form name of the file to be uploaded is userfile.

Method 2:

In fact, there is still a solution, if the file domain is another name. For example:

Set

The code is as follows:

$ This-> upload-> do_upload ();

Change

The code is as follows:

$ This-> upload-> do_upload ('imgfile ');

That's all!

2. form type

The form must use form_open_multipart. when HTML is formed, an attribute enctype = "multipart/form-data" is added. this is actually common sense. just pay attention to it.

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.