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.