Home > Backend Development > PHP Problem > How to modify the maximum limit of uploaded files in php

How to modify the maximum limit of uploaded files in php

青灯夜游
Release: 2023-03-17 18:26:01
Original
3055 people have browsed it

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.

How to modify the maximum limit of uploaded files in php

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

How to modify the maximum limit of uploaded files in php

##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_time

Look for it in php.ini

max_execution_time

The default is 30 seconds. Change to

max_execution_time = 0
Copy after login

0 to indicate no limit

How to modify the maximum limit of uploaded files in php

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 to

post_max_size = 32M
Copy after login

How to modify the maximum limit of uploaded files in php

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 to

upload_max_filesize = 32M
Copy after login

How to modify the maximum limit of uploaded files in php

Another 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template