Table of Contents
php.ini cannot upload large files Solution" >php.ini cannot upload large files Solution
Home Backend Development PHP Tutorial Why can't php large files be uploaded?

Why can't php large files be uploaded?

Jul 09, 2018 pm 05:51 PM

This article mainly introduces the reasons and solutions for PHP large file upload failure. It has certain reference value. Now I share it with everyone. Friends in need can refer to it

php.ini cannot upload large files Solution

1. Open php.ini

2. Find post_max_size: (modify upload size limit)

The maximum value for form submission. This item does not limit the size of a single uploaded file, but The default is 8m for limiting the submitted data of the entire form. Set it to the value you need. It is recommended that this parameter be set larger than upload_max_filesize

3. Find file uploads :(Modify upload switch restrictions)

Whether to allow file uploading via http switch, confirm file_uploads = on

4. Find upload_tmp_dir:(Modify upload temporary file restrictions)

The file is uploaded to the place where temporary files are stored on the server. If not specified, the system's default temporary folder will be used. If the system error prompts "xxx temporary directory xxx", you need to set a valid directory for this directory. If no error is reported, don't worry.

5. Find upload_max_filesize:(Modify upload size limit)

The maximum allowed upload file size, the default is 2m, Set this parameter to the value you need. It is recommended not to exceed the post_max_size value, because it is controlled by the post_max_size value (even if upload_max_filesize is set to 1g,

and post_max_size is only set to 2m, it is greater than 2m The file still cannot be uploaded because it is controlled by the post_max_size value)

6. If you want to upload a file larger than 8m, you also need to set the following parameters: (Modify upload time limit)

Find max_execution_time = 600; The maximum time value (seconds) for each php page to run, the default is 30 seconds

max_input_time = 600; The maximum time required for each PHP page to receive data, the default is 60 seconds

memory_limit = 8m; The maximum memory required for each PHP page, the default 8m

nginx method to upload large files solution

1.Client_body_buffer_size should be set as large as possible. This is based on speed considerations. If the uploaded file always has to be written to the disk because it is set too small, the speed will be too slow.

2.client_body_temp_path The path must have writable permissions. This is an obvious mistake. Just correct it

3.client_max_body_size sets the maximum value for uploaded files. This is based on security considerations. We believe that normal users will not or basically will not upload files that are too large.

Can be set to client_max_body_size 100m; or set this value according to your own business.

1. Open php.ini

##2. Find post_max_size: (modify upload size limit)

Maximum value for form submission. This item does not limit the size of a single uploaded file, but limits the submission data of the entire form. The default is 8m. Set it to what you need. Value, it is recommended that this parameter be set larger than upload_max_filesize

3. Find file uploads:(Modify the upload switch limit)

Whether to allow file uploading via http switch, confirm file_uploads = on

4. Find upload_tmp_dir:(modify upload temporary file Restrictions)

# Files are uploaded to the place where temporary files are stored on the server. If not specified, the system default temporary folder will be used. If the system error prompts "xxx "Temporary directory xxx", you need to set a valid directory for this directory. If no error is reported, don't worry.

5. Find upload_max_filesize:(Modify the upload size limit )

The maximum allowed upload file size, the default is 2m, set it to the value you need. This parameter is not recommended to exceed the post_max_size value, because it is controlled by post_max_size value (even if upload_max_filesize is set to 1g,

When post_max_size is only set to 2m, files larger than 2m still cannot be uploaded because it is controlled by the post_max_size value)

6. If you want To upload files larger than 8m, you also need to set the following parameters: (modify the upload time limit)

Look for max_execution_time = 600; the maximum time for each PHP page to run Value (seconds), default is 30 seconds

max_input_time = 600; Maximum time required for each php page to receive data, default is 60 seconds

memory_limit = 8m; The maximum memory required for each php page, the default is 8m

nginx method to upload large files solution

1.client_body_buffer_size Try to set it as large as possible. This is based on speed considerations. If the setting is too small, the uploaded file always needs to be written to the disk, and the speed will be reduced. It's just too slow.

2.client_body_temp_path The path must have writable permissions. This is an obvious mistake. Just correct it

3.client_max_body_size sets the maximum value for uploaded files. This is based on security considerations. We believe that normal users will not or basically will not upload files that are too large.

Can be set to client_max_body_size 100m; or set this value according to your own business.

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Usage of heredoc in php

Later static binding in php

The above is the detailed content of Why can't php large files be uploaded?. For more information, please follow other related articles on the PHP Chinese website!

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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

See all articles