The client browser uploads the file, which is implemented by the form file control in HTML, and if the type of the input box is set to file, the pop-up window selects the local file for uploading when clicked.
It is important to note that if a file is uploaded in the form, the form should be sent whether the encoding is set to not encode enctype= "Multipart/form-data".
When the user clicks on the form submission, the file is sent to the receiving server-side script, such as PHP. In PHP, you can use the predefined variable $_files to receive the sent file.
The information received is as follows:
$_files[' myfile ' [' name '] refers to the name of the file being uploaded
$_files[' myfile ' [' type '] refers to the type of file being uploaded
$_files[' myfile ' [' size '] refers to the size of the uploaded file, in bytes (B)
$_files[' myfile ' [' tmp_name '] means the file name of the temporary copy of the file being uploaded to the server, and the file is moved to the specified directory and the pro file is automatically destroyed.
$_files[' myfile ' ["error"] refers to the status code of errors that may appear in the file upload, as explained in the following context.
Error status Code:
0: No error occurred, file upload succeeded.
1: The uploaded file exceeds the value of upload_max_filesize option limit in php.ini
2: The size of the uploaded file exceeds the value specified by the Max_file_size option in the HTML form
3: The file is only partially uploaded.
4: No files are uploaded
6: The Temp folder cannot be found. PHP 4.3.10 and PHP 5.0.3 introduced.
7: File write failed. PHP 5.1.0 introduced.
When $_files[' myfile ' [ERROR] returns to 0 to indicate that the file has been uploaded successfully, we need to use the PHP move_uploaded_file () function to move the uploaded temporary file to a new location so that the file is saved to the server.
This article is from the "Grow from Blog" blog, be sure to keep this source http://lxqybyq.blog.51cto.com/7868338/1839469
PHP File Upload Processing