Home > Article > Backend Development > How to modify the maximum limit of uploaded files in php
Modification method: 1. Open the php.ini configuration file; 2. Find the "max_execution_time" item and modify its value (maximum execution time) to the required value; 3. Find the "post_max_size" item and change Change its value to the required value; 4. Find the "upload_max_filesize" item and change its value to the required value.
The operating environment of this tutorial: windows7 system, PHP8 version, DELL G3 computer
PHP uploading large files takes up a lot of resources, so it needs to be uploaded The size is limited. The following are the three relevant parameters:
client_max_body_size
upload_max_filesize
post_max_size
By default, the PHP upload file size limit is 2M. If it exceeds 2M, an error will be reported.
If the image or compressed package we upload exceeds 2M, we need to modify the maximum upload limit of PHP's configuration file.
How to modify the maximum limit of uploaded files in PHP
1. Open the php.ini file
Left-click wamp, select php, and select php.ini in the pop-up window
##2. Modify the max_execution_time value
For general file upload, unless the file is very small. For example, a 5M file may take more than a minute to upload. But in PHP, the default maximum execution time of this page is 30 seconds. That is to say, if it exceeds 30 seconds, the script will stop executing.This will lead to the inability to open the web page. At this time, we can modify max_execution_timeLook for it in php.inimax_execution_time
max_execution_time = 00 to indicate no limit
3. Modify the post_max_size value
Modify post_max_size to set the maximum size allowed for POST data. This setting also affects file uploads. The default post_max_size of php is 2M. If the POST data size is larger than post_max_size, $_POST and $_FILES superglobals will be empty. Find post_max_size. Change topost_max_size = 32M
4. Modify the upload_max_filesize value
Many people will change the second step. But when uploading files, the maximum is still 8M.Why? .We also need to change a parameter upload_max_filesize to indicate the maximum size of the uploaded file. Look for upload_max_filesize, the default is 8M and change it toupload_max_filesize = 32MAnother thing to note is that post_max_size is better than upload_max_filesize.Recommended learning : "
PHP Video Tutorial"
The above is the detailed content of How to modify the maximum limit of uploaded files in php. For more information, please follow other related articles on the PHP Chinese website!