During a simple form Upload test, the $ _ FILES array in the php script on the server is empty. in this way, the information uploaded from the browser cannot be obtained. why? Google, find... during a simple form Upload test, the $ _ FILES array in the php script on the server is empty, so that the information uploaded from the browser cannot be obtained. why?
Google:
Php file Upload $ _ FILES array is empty solution
The first reason described in this article is the situation encountered during the test. that is, the attribute enctype = "multipart/form-data" is not set in the form of the file to be uploaded ".
The following is the full text of this post:
Php:
When using php to upload FILES, an empty array is displayed when $ _ FILES is printed in the background. this problem may be caused by the following two reasons:
Cause of form type or php setting:
1. form type:
The form encoding type of the file to be uploaded must be set to enctype = "multipart/form-data". to transmit big data, POST is generally used for submission.
2. php settings:
The default post_max_size of php is 2 MB. if the size of POST data is larger than that of post_max_size $ _ POST and $ _ FILES, it is null. the solution is as follows:
1. upload an ordinary file unless the file is small. like a 5 MB file, it may take more than one minute to complete the upload. however, in php, the longest execution time of this page is 30 seconds by default. that is to say, the script is stopped after 30 seconds. this leads to the failure to open the webpage. in this case, we can modify max_execution_time in php. the default value of max_execution_time in ini is 30 seconds. change to max_execution_time = 0 (the range can be modified to PHP_INI_ALL). 0 indicates no limit.
Or set ini_set ('max _ execution_time ', 0) in the PHP file header );
2. modify post_max_size to set the maximum size allowed by POST data. This setting also affects file upload. Change post_max_size to post_max_size = 150 M (the range can be changed to PHP_INI_PHP_INI_PERDIR)
3. many people will change the second step. but the maximum size of the uploaded file is still 8 MB. why? we need to change the parameter upload_max_filesize to indicate the maximum size of the uploaded file. Find upload_max_filesize. the default value is 8 M. change it to upload_max_filesize = 100 M (the range can be changed to PHP_INI_PHP_INI_PERDIR)
In addition, it should be noted that post_max_size is the size of the entire expression, while upload_max_filesize is the size of the uploaded file. The former should be greater than the latter.