How to increase the PHP upload file size
Two directives control upload size, not one — miss the second and a bigger upload_max_filesize changes nothing at all.
Two separate PHP directives control how large a file a script is allowed to accept, and this is the single most common mistake made when raising an upload limit: raising upload_max_filesize alone does nothing if post_max_size is still lower. The whole request — the file plus every other field in the form — has to fit under post_max_size first. If it does not, PHP rejects the request before your script or application ever sees the file, often with no clear error at all.
The two directives
| Directive | Controls |
|---|---|
upload_max_filesize | The maximum size of a single uploaded file. |
post_max_size | The maximum size of the entire form submission the file is part of, including every other field. Must be equal to or larger than upload_max_filesize. |
If upload_max_filesize is 64M and post_max_size is still 8M, uploads over 8M fail regardless of what the first setting says. A safe pattern is to set post_max_size a little above upload_max_filesize to leave room for the rest of the form data — for example 64M and 72M rather than identical values.
Where to change them
On shared hosting, both directives can be changed without root access:
- The PHP settings area of your control panel normally lists both together, since they are almost always changed as a pair.
- A user-level
php.inior.user.inifile in the site's directory:
upload_max_filesize = 64M
post_max_size = 72M
On a PHP-FPM setup, which is what most modern shared hosting runs, an Apache-style php_value upload_max_filesize 64M line in .htaccess is either ignored or triggers a 500 error, because FPM does not process legacy mod_php directives placed there. Use the control panel or a user ini file instead — see how to use .htaccess for what that file is and is not for.
Choosing a value
| What you are uploading | Reasonable starting point |
|---|---|
| Documents, images for a blog or product page | upload_max_filesize 16M, post_max_size 20M |
| Large photos, PDFs, design files | upload_max_filesize 64M, post_max_size 72M |
| Video files or full database exports through a browser upload | upload_max_filesize 512M or higher, post_max_size a little above that |
For anything in the last row, it is worth asking whether a browser upload is really the right tool. Very large files are more reliably moved over SSH or by rsync than through a form that has to hold the whole file in memory and stay connected for as long as the transfer takes — a dropped connection partway through a 40-minute browser upload wastes far more time than the same file copied over a resumable transfer.
A third limit people forget: memory_limit
A file has to be held in memory somewhere between being received and being written to disk or processed, so memory_limit needs enough headroom for the largest file you plan to accept plus whatever else the script is doing. If uploads fail silently even after raising both upload directives, check increasing the PHP memory limit next — a script that runs out of memory partway through processing an upload can fail in ways that look identical to hitting the size limit itself.
Confirming the new values took effect
<?php
echo ini_get('upload_max_filesize') . "\n";
echo ini_get('post_max_size');
If either value still shows the old number, the most likely cause is editing the wrong PHP version — see checking your PHP version — since a site can have more than one available and only the one actually serving requests matters.
Why an upload can still fail after this
- A web server or reverse proxy limit set independently of PHP. Some platforms cap request body size at that layer too, and a request over that ceiling never reaches PHP at all, so raising PHP's own settings has no effect on it.
- max_execution_time on a slow connection. A large file taking a long time to transfer can trip the execution time limit before the upload even finishes — see increasing max execution time.
- The application's own setting. Many CMS platforms and form plugins apply an additional limit of their own on top of PHP's, which has to be raised separately inside the application.
When a large upload fails without a clear message on screen, read the PHP error log rather than guessing — PHP records the specific reason a POST body or upload was rejected, which narrows down which of the limits above actually applied.
Related reading
Where memory_limit is set, how to raise it safely, and why a higher number is not always the actual fix for an exhausted-memory error.
How to use .htaccess on your hosting accountOne file that controls redirects, rewrites and access rules for a whole folder — and one typo in it that can take the site offline.
How to debug a blank white page in PHPA white screen means PHP hit an error and showed nothing — here is how to make it show you exactly what happened and where.
How to call an external API from PHPcURL, an authentication header and a decoded JSON response — the three parts of calling any external API from a PHP script.