: This article mainly introduces ThinkPHP file upload summary. if you are interested in the PHP Tutorial, please refer to it. This article summarizes several methods to upload files in combination with JavaScript and php.
- Test environment Thinkphp3.2 and phpStudy2014 (Apache + php 5.3)
- Either way, you must first configure the php file size to be uploaded.
Open php. ini and modify the following three items:
Max_execution_time = the longest execution time (0 indicates no limit)
Post_max_size = maximum allowed size
Upload_max_filesize = maximum size of the uploaded file
Thinkphp directly uploads files
The upload class provided by Thinkphp supports multifile Upload. For more information, see
Note: to add the form label, enctype = "multipart/form-data"
If you want to upload images without refreshing, you need to use ajax to upload the images, and then set src based on the returned Image address. However, you cannot add enctype to ajax. Therefore, you need other methods.
Iframe http://blog.csdn.net/hytfly/article/details/6267229 available
Xhr http://updates.html5rocks.com/2012/04/Processing-XHR2-file-uploads-in-PHP can also be used
Thinkphp + uploadify Upload files
Uploadify official website: http://www.uploadify.com/
An example of testing: http://www.thinkphp1.cn/topic/30225.html
Thinkphp + plupload Upload files
Plupload official website: http://www.plupload.com/
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above section introduces ThinkPHP's file upload summary, including some content, and hopes to help those who are interested in PHP tutorials.