<form enctype= "Multipart/form-data" action= "URL" method= "POST" > <input type= "file" name= "Brand_logo"/> </form>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/90/63/wKiom1jwS4-zEGAmAAAnSz5MD2E184.png "title=" Qq20170414120751.png "alt=" Wkiom1jws4-zegamaaansz5md2e184.png "/>
After uploading the image Test1.png, print the $_files array and print the results as follows
Array (size=1) ' brand_logo ' = = Array (size=5) ' name ' = = String ' test1.png ' (length=9) ' type ' + = St Ring ' image/png ' (length=9) ' tmp_name ' = = String ' J:\wamp\tmp\phpEA41.tmp ' (length=23) ' ERROR ' = int 0 ' size ' = = int 71194
The contents of the $_files array are as follows:
$_files[' myFile ' [' name '] the original name of the client file
The MIME type of the $_files[' myFile ' [' type '] file requires the browser to provide support for that information, such as "Image/gif"
$_files[' myFile ' [' Size '] the size of the uploaded file, in bytes
$_files[' myFile ' [' tmp_name '] files are uploaded on the server after the temporary file name stored in the system is generally default, can be specified in the Upload_tmp_dir of php.ini , but with putenv () function setting is not working
$_files[' myFile ' [' Error '] and the file upload related error code,[' ERROR '] is added in the PHP 4.2.0 version, the following is its description:(They are PHP3.0 later became a constant )
UPLOAD_ERR_OK value:0; No error occurred, file upload succeeded
Upload_err_ini_size Value:1; the uploaded file exceeds The value of the upload_max_filesize option limit in php.ini
Upload_err_form_size value:2; the size of the uploaded file exceeds the the value specified by the max_file_size option in the HTML form
Upload_err_partial Value:3; files are only partially uploaded
Upload_err_no_file Value:4; no files were uploaded, value:5; upload file size of 0
Note:
1. after the file is uploaded, it is stored in the temp directory by default, and it must be removed from the temp directory or moved elsewhere, if not, it will be deleted. That is, regardless of whether or not the upload succeeds, the files in the temp directory will be deleted after the script executes. So before you delete it, copy it to another location using PHP 's copy () function, and it's time to upload the file.
2. before the PHP 4.1.0 version, the name of the array is $HTTP _post_files, and it is not an automatic global variable like $_files. PHP 3 does not support $HTTP _post_files arrays.
3. When uploading a file with a form, be sure to add the attribute content enctype= "Multipart/form-data", otherwise use $_files[filename] An exception is reported when getting file information.
The code is as follows
<form enctype= "Multipart/form-data" action= "URL" method= "POST" > <input name= "myFile" type= "File" > & Lt;input type= "Submit" value= "Upload file" ></form>
$_files in PHP