Notes for file Upload

Source: Internet
Author: User
Notes for uploading files in PHP: 1. in form, set the method attribute to post, and enctype attribute to multipart/form-data; 2. upload file size limit 1) PHP configuration file (PHP3 is php3.ini, PHP4 is php. in ini), upload_max_filesize is used to limit the maximum size of PHP.

Notes for uploading files in PHP:
1. in form, set the method attribute to post, and enctype attribute to multipart/form-data;
2. restrictions on the size of uploaded files
1) PHP configuration file (PHP3 is php3.ini and PHP4 is php. in ini), upload_max_filesize is used to limit the maximum size of uploaded files that PHP can process. measured in bytes. the default value is 2097152 = 2*1024*1024 bytes (2 MB ), 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 named MAX_FILE_SIZE to the form. its value is the maximum number of bytes that can be uploaded by the client, of course, this value cannot exceed the PHP configuration file (PHP3 is php3.ini, and PHP4 is php. ini) in upload_max_filesize. Note that this input box must be placed in front of all file-type input boxes; otherwise, it is invalid;
3. temporary directory for storing uploaded files
The upload_tmp_dir in the PHP configuration file (PHP3 is php3.ini and PHP4 is php. ini) is used to set
Upload a temporary directory for storing files. Note that the account running Apache must have the read and write permissions on this directory,
At the same time, you must restart Apache after the modification, otherwise it will not take effect;
4. after the PHP program runs, the system automatically deletes the temporary files uploaded to the server, therefore, if you want to process uploaded files (such as copying files to another directory or putting the file content in the database), you must do so in this PHP program.

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.