search
HomeBackend DevelopmentPHP ProblemHow to modify the file upload size limit in php

How to modify the file upload size limit in php

Aug 29, 2019 pm 04:40 PM
phpRevisesize limitFile Upload

How to modify the file upload size limit in php

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools