Several points worth noting when uploading files_PHP Tutorial

WBOY
Release: 2016-07-13 17:25:27
Original
891 people have browsed it

Several points worth noting when uploading files in PHP:
1. In the form form, set the method attribute to post and the enctype attribute to multipart/form-data;
2. Upload file size limit
1) The upload_max_filesize in the PHP configuration file (PHP3 is php3.ini, PHP4 is php.ini) is used to limit the maximum upload file size that PHP can handle, calculated in bytes, the default is 2097152=2*1024*1024 Bytes (2 megabytes), please note that you must restart Apache after modifying the file, otherwise it will not take effect;
2) You can add a hidden type input box to the form, named MAX_FILE_SIZE, and its The value is the maximum number of bytes allowed to be uploaded by the client. Of course, this value cannot exceed the upload_max_filesize in the PHP configuration file (PHP3 is php3.ini, PHP4 is php.ini). Note that this input box must be placed in all file types. in front of the input box, otherwise it will be invalid;
3. The uploaded file temporary storage directory
upload_tmp_dir in the PHP configuration file (PHP3 is php3.ini, PHP4 is php.ini) is used to set
The uploaded file is temporarily stored in the directory. Note that the account running Apache must have read and write permissions on this directory.
At the same time, you must restart Apache after making the modification, otherwise it will not take effect;
4. After the PHP program is finished running , the system automatically deletes the temporary files of the uploaded files on the server, so if you want to process the uploaded files (such as copying to another directory or putting the file contents into the database), you must do it in this PHP program.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532064.htmlTechArticleA few points worth noting when uploading files in PHP: 1. Set the method attribute to post in the form , the enctype attribute is set to multipart/form-data; 2. Limitation on uploaded file size 1) PHP configuration file...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!