File upload and download learning notes (1)---File Upload principle and configuration

Source: Internet
Author: User

A: The principle: To upload the client's files to the server-side temporary directory , and then move the server-side temporary files to the specified directory .

II: Configuration of the client

    1. form must be a POST method
    2. form must be added enctype= "Multipart/form-data" property

Both are indispensable.

Three: Move temporary files to the specified directory

Two methods: 1:move_uploaded_file ($filename, $destination)

2:copy ($source, $dest)

Four: Configuration in the php.ini

When searching for uploads in php.ini, you will see the configuration of the uploads module

The first item: File_uploads=on Open File Upload function

Second item: upload_tmp_dir= "C:\xampp\tmp" Temp directory

The third item: upload_max_filesize maximum file size allowed to upload

Item Fourth: Post_max_size the size of data passed through the Post method

Fifth item: Max_file_uploads=20 upload up to 20 files at a time

About the configuration of resources
Max_execution_time=30 the maximum allowable execution time, in seconds, before the script parser terminates. Prevent the program from writing poorly and take advantage of server resources
max_input_time=60 script parsing the maximum time for input data post, GET, etc.
Max_input_nesting_level = 64 Sets the nesting depth of the input variable
Memory_limit =128m Maximum single thread (Web request) for independent memory usage
Max_input_vars = 1000 How many input variables are accepted

V: Error number resolution

0 upload successfully uploaded to temp directory successfully
1 exceeds the value of upload_max_filesize
2 exceeded the value specified by max_file_size (form)
3 files are only partially uploaded
4 No files were uploaded
6 Temp directory not found
7 File Write Failed
8 uploaded file interrupted by php extension

File upload and download learning notes (1)---File Upload principle and configuration

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.