How to modify the size limit of PHP upload files:
1. General file upload, unless the file is very small. Like a 5M file, it will probably 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 results in the inability to open the web page. At this time we can modify max_execution_time.
Look in php.ini:
max_execution_time
The default is 30 seconds, change it to:
max_execution_time = 0
0 Indicates no limit.
Related recommendations: "PHP Getting Started Tutorial"
2. Modify post_max_size to set the maximum size allowed for POST data. This setting also affects file uploads.
php The default post_max_size is 2M. If the POST data size is greater than post_max_size $_POST and $_FILES superglobals will be empty.
Find post_max_size and change it to:
post_max_size = 150M
3. Many people will change the second step, but the maximum size when uploading files 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 to:
upload_max_filesize = 100M
In addition, it should be noted that post_max_size is better than upload_max_filesize.
4. Upload 413 error
The reason for this error is that the entity body part sent by the client is larger than the server can or hopes to handle. Under normal circumstances we cannot see this status code. Because the browser will not send too much data to the website, but the problem may occur in the interface interaction between servers.
The reason for this problem in nginx is that the request entity is too long. This situation generally occurs when the Post data of the Body content in the Post request is too large, such as uploading a large file that is too large or has a lot of POST data.
Solution:
Open the nginx main configuration file nginx.conf, find the http{} section, modify or add the value of client_max_body_size.
client_max_body_size 20m;
The above is the detailed content of How to modify the file upload size limit in php. For more information, please follow other related articles on the PHP Chinese website!