File Upload form
< Form Enctype="Multipart/form-Data" Action = "Url" Method = "Post" > < Input Type = "Hidden" Name = "Max_file_size" Value = "1000" > < Input Name="Myfile" Type = "File" > < Input Type = "Submit" Value = "Upload files" > < / Form >
|
The $ _ FILES array contains the following content:
$ _ FILES ['myfile'] [' Name '] Original name of the client file.
$ _ FILES ['myfile'] [' Type '] MIME type of the file, which must be supported by the browser, such as "image/GIF ".
$ _ FILES ['myfile'] [' Size '] Size of the uploaded file, in bytes.
$ _ FILES ['myfile'] [ 'Tmp _ name' ] The temporary file name stored on the server after the file is uploaded. This is generally the default file name. It can be specified in upload_tmp_dir of PHP. ini, but the putenv () function setting does not work.
$ _ FILES ['myfile'] [' Error '] Errors related to the File Upload Code . ['Error'] is added in PHP 4.2.0. The following is its description: (they become constants after php3.0)
Upload_err_ OK
Value: 0. If no error occurs, the file is uploaded successfully.
Upload_err_ini_size
Value: 1; the uploaded file exceeds the limit of the upload_max_filesize option in PHP. ini.
Upload_err_form_size
Value: 2; the size of the uploaded file exceeds the value specified by the max_file_size option in the HTML form.
Upload_err_partial
Value: 3; only part of the file is uploaded.
Upload_err_no_file
Value: 4; no file is uploaded.
Value: 5; the size of the uploaded file is 0.
After the file is uploaded, it is stored in the temporary directory by default. You must delete it from the temporary directory or move it to another place. If it does not exist, it will be deleted. That is, no matter whether the upload is successful or not, the files in the temporary directory will be deleted after the script is executed. Therefore, you must copy the file to another location using the copy () function of PHP before deleting the file. In this case, the file upload process is completed.