Home > Backend Development > PHP Tutorial > How to Configure PHP for Large File Uploads?

How to Configure PHP for Large File Uploads?

Mary-Kate Olsen
Release: 2024-10-29 19:31:29
Original
643 people have browsed it

How to Configure PHP for Large File Uploads?

Configuring PHP to Support Large File Uploads

Uploading large files (e.g., ~100 MB) using PHP requires adjustments to the PHP configuration file (php.ini). Here are the key changes you need to make:

1. PHP Configuration

  • upload_max_filesize: Sets the maximum size of files that PHP can upload. Increase this value to accommodate larger files.
  • post_max_size: Defines the maximum size of POST requests, which can include uploaded files. Ensure it's larger or equal to the upload_max_filesize.
  • max_input_time: Specifies the maximum duration for a PHP script to receive a POST request. Increase this value for larger uploads to avoid timeouts.

2. Apache Configuration (if applicable)

  • LimitRequestBody: Sets the maximum size of HTTP request bodies, which include form data and file uploads. Ensure it's greater than or equal to upload_max_filesize and post_max_size.

Configuration Example:

; php.ini
upload_max_filesize = 100M
post_max_size = 110M
max_input_time = 600

; .htaccess
LimitRequestBody 110M
Copy after login

Note: Remember to restart your web server (e.g., Apache) after making these changes to ensure they take effect.

The above is the detailed content of How to Configure PHP for Large File Uploads?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template