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
- form must be a POST method
- 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