Home  >  Article  >  Backend Development  >  How to modify the file size limit of php upload files

How to modify the file size limit of php upload files

藏色散人
藏色散人Original
2019-11-09 11:26:253630browse

How to modify the file size limit of php upload files

How to modify the size limit of PHP upload files

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 may 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 web page cannot be opened. At this time, we can modify max_execution_time

Look for

max_execution_time

in php.ini. The default is 30 seconds. Change it to

max_execution_time = 0

0 to indicate no limit.

2. Modify post_max_size Sets 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 = 150M

3. 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 uploaded The maximum size of the 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 greater than upload_max_filesize.

4. Upload reports 413 error,

The reason for this error is that the entity body 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;

Recommended : "PHP Tutorial"

The above is the detailed content of How to modify the file size limit of php upload files. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn