How to modify the php upload file file size limit
How to modify PHP upload file size limit
1. General file upload, unless the file is very small. Like a 5M file, it is likely to take more than a minute to upload.
But in php, the default maximum execution time of the page is 30 seconds. That is to say, if it exceeds 30 seconds, the script will stop executing.
This leads to the situation that the webpage cannot be opened. At this time, we can modify max_execution_time
Find in php.ini
max_execution_timeThe default is 30 seconds. Change to
max_execution_time = 00 means no limit
2. 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 to
post_max_size = 150M3. Many people will change the second step. But the maximum upload file is still 8M.
Why? We also need to change a parameter upload_max_filesize to represent the maximum size of the uploaded file.
Find upload_max_filesize, the default is 8M to
upload_max_filesize = 100MAnother thing to note is that post_max_size is better than upload_max_filesize.
4. Upload a 413 error,
The reason for this error is that the client sent a larger entity body part than the server can or wants to handle. Under normal circumstances, we do not see this status code. Because the browser does not send too much data to the website, but the interface interaction between the servers may have this problem.
The reason for this problem with nginx is that the request entity is too long. This usually occurs when the body content Post data is too large when the Post request is made, such as uploading a large file that is too large and POST data is relatively large.
Solution:
Open the nginx main configuration file nginx.conf, find the http{} section, and modify or add the value of client_max_body_size
client_max_body_size 20m;Recommended: "PHP Tutorial"
The above is the detailed content of how to modify the file size limit of php upload files. For more details, please pay attention to other related articles of Gxlcms!
