In PHP $

Source: Internet
Author: User
Tags error code file size file upload html form http post ini php and

  This article is mainly on the use of $_files in PHP and notice of the introduction, the need for friends can come to the reference, I hope to help you.

$_files: Variable submitted to script via HTTP Post file, similar to old array $http_post_files array (still valid but against use) details can be found in the Post method upload   $_files array contents as follows:   $ _files[' myFile ' [' name '] Client file's original name           $_files[' myFile ' [' type '] file MIME type, Browsers are required to provide support for this information, such as "Image/gif"           $_files[' myFile ' [' size '] uploaded file size in bytes     & nbsp     $_files[' myFile ' [' tmp_name '] files are stored in the server after the temporary file name, generally the system default, can be specified in PHP.ini Upload_tmp_dir, but with putenv () Function settings are not functional         $_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 become constant after PHP3.0   UPLOAD_ERR_OK value: 0; No error occurred, file upload success   upload_err_ini_size value: 1; Uploaded file exceeds php.ini upload_max_filesize option limit               upload_err_form_size value: 2; Upload text The size of the piece exceeds 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 are uploaded, Value: 5; Upload file size 0                         NOTE:   1. When the file is uploaded, it is stored in the temporary directory by default, and it must be removed from the temporary directory or moved to another location, if not, it will be deleted. That is, whether or not the upload succeeds, the files in the temp directory will be deleted after the script is executed. So before you delete it, copy it to another location using PHP's copy () function, which completes the upload file process.   2. Before PHP version 4.1.0, the name of the array was $HTTP _post_files, and it was not an automatic global variable like $_files. $HTTP _post_files Array is not supported in PHP 3.   3. When uploading files with form, be sure to add the attribute content enctype= "Multipart/form-data", otherwise use $_files[filename] Get file information will be reported abnormal.     Code as follows: <form enctype= "Multipart/form-data" action= "URL" method= "post" >         <input name= "MyFile" type= "file" >        <input type= "Submit" value= "Upload file" > </form >  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.