Knowledge
PHP file upload exceeds upload_max_filesize
#PHP
When a file upload silently fails or is empty, PHP itself is usually rejecting it because it is larger than upload_max_filesize or post_max_size. This is the PHP-side companion to the nginx 413 error.
Published by Mark van Eijk on June 23, 2026 · 1 minute read
About the error
Unlike most errors, this one is quiet. The upload just doesn't arrive, $_FILES is empty, or you see UPLOAD_ERR_INI_SIZE in the file's error key. PHP discarded the file before your code ever ran.
This is distinct from, but often confused with, the 413 Request Entity Too Large error. That one is nginx rejecting the request before it reaches PHP. If you've already raised nginx's client_max_body_size and uploads still fail, PHP's own limits are the next place to look.
Why do I see this error
Two PHP settings cap upload size, and the lower of the two wins:
upload_max_filesize, the maximum size of a single uploaded file.post_max_size, the maximum size of the entire POST body (which must be larger thanupload_max_filesize, with room for other fields).
If either is smaller than the file, PHP drops it.
Solution
Raise both values in your php.ini. post_max_size should be a bit larger than upload_max_filesize:
upload_max_filesize = 100M
post_max_size = 110M
While you're there, check these related limits don't cut a large upload short:
max_file_uploads = 20
max_execution_time = 120
memory_limit = 256M
Reload PHP-FPM so the changes take effect:
systemctl reload php8.3-fpm
Don't forget the layers in front of PHP
A large upload has to pass through every layer to succeed. All of these must be big enough:
- nginx, via
client_max_body_size, see 413 Request Entity Too Large. - PHP, via
upload_max_filesizeandpost_max_sizeabove. - Your application's own validation, for example a Laravel
max:rule on the file.
Verify the active PHP values with:
php -i | grep -E 'upload_max_filesize|post_max_size'
Note that the CLI and the FPM SAPI can use different php.ini files, so check the FPM one (/etc/php/8.3/fpm/php.ini) for web uploads.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!
Related articles
How to run PHP files
When a file upload silently fails or is empty, PHP itself is usually rejecting it because it is larger than upload_max_filesize or post_max_size. This is the PHP-side companion to the nginx 413 error.
PHP Fatal error: Class "X" not found
When a file upload silently fails or is empty, PHP itself is usually rejecting it because it is larger than upload_max_filesize or post_max_size. This is the PHP-side companion to the nginx 413 error.