Home  >  Article  >  Backend Development  >  PHP upload size limit modification

PHP upload size limit modification

韦小宝
韦小宝Original
2018-02-26 09:58:4512491browse

Uploading is a very common and important point in PHP development, and the size of PHP upload is limited. In order to better improve the upload speed of PHP, we need to modify the upload size limit, okay! Let’s take a look at how to modify PHP upload restrictions!

  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 The longest page execution time is 30 seconds. That is to say, if it exceeds 30 seconds, the script will stop executing.
    This will lead 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 to

max_execution_time = 0

0 to indicate 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 = 150M

3. Many people will change the second step. But when uploading files, the maximum size 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.

More Upload articles:

In PHP programs, we often encounter this problem. When uploading attachments, many attachments, such as pictures, etc., are successfully uploaded, but in fact only 20 attachments exist, or directly Failed to upload error.

How to break through the max_file_uploads limit of PHP uploading multiple files

This article mainly introduces the ZenTao attachment size limit and the PHP upload file size limit , students who are interested in PHP tutorials can refer to it.

ZenTao attachment size limit, PHP upload file size limit

The above is the detailed content of PHP upload size limit modification. 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