File_uploads = on; whether to allow file upload over HTTP. ON is enabled by default.
Upload_tmp_dir; upload the file to the place where the temporary file is stored on the server. If it is not specified, the default temporary folder will be used.
Upload_max_filesize = 8 m; Wangwen business, that is, the maximum file size allowed to be uploaded. The default value is 2 MB.
Post_max_size = 8 m; the maximum value that can be received by posting a form to PHP, including all values in the form. The default value is 8 MB.
Use the. htaccess file
Write in htaccess
Php_value post_max_size 12 m
Php_value upload_max_filesize 12 m
Php_value max_execution_time 120
Php_value max_input_time 240
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 causes the web page to fail to be opened. In this case, we can modify max_execution_time.
Search in php. ini
The default value is 30 seconds.
Max_execution_time = 0
0 indicates no limit
Another way is to add
To set the longest page execution time.
Set_time_limit (0); // 0 indicates no limit
In addition, post_max_size is better than upload_max_filesize.
Next, we will briefly introduce some parameters involved in php file upload:
· File_uploads: whether to allow file upload over HTTP. The default value is ON, that is, whether to allow upload_tmp_dir to indicate the temporary directory of files uploaded by PHP. To upload files, make sure that the server does not have the permission to close temporary files and write to folders. If not specified, PHP uses the system default value. Upload_max_filesize: maximum size of the file to be uploaded. The default value is 2Mpost_max_size, which controls the maximum data size that PHP can receive in a form submission using the POST method. If you want to use the php file upload function, you need to change this value to a value greater than upload_max_filesize.
· Max_input_time limits the time for receiving data through POST, GET, and PUT in seconds. If the application's running environment is on a low-speed link, you need to add this value to adapt to the more time required to receive data.
· Memory_limit: to avoid using a large amount of available system memory for running scripts, PHP allows you to define the memory usage limit. The memory_limit variable is used to specify the maximum memory capacity variable memory_limit that a single script program can use. The value of memory_limit should be greater than the value of post_max_size.
· Max_execution_time sets the time for PHP to wait for the script to be executed before the script is forcibly terminated. The time is calculated in seconds. This variable is useful when the script enters an infinite loop state. However, when there is a legal activity that takes a long time to complete (such as uploading large files), this function will also cause operation failure. In this case, you must consider increasing the value of this variable to prevent PHP from closing the script when the script is executing an important process.