What the message looks like
The uploaded file exceeds the upload_max_filesize directive in php.ini
PHP Warning: POST Content-Length of 52428900 bytes exceeds the limit of 8388608 bytes in Unknown on line 0Common causes
upload_max_filesizein thephp.iniof PHP-FPM is smaller than the file.post_max_sizeis smaller than the upload plus other form data (then$_FILESis silently empty).- nginx
client_max_body_sizeis smaller and answers 413 before PHP sees the file. - The setting was changed in the CLI
php.iniinstead of the FPM one. - A pool or
.user.inioverrides the global value, or the upload is so slow thatmax_input_timeormax_execution_timeends it.
Check
- Effective values in the FPM php.ini
grep -E '^(upload_max_filesize|post_max_size|memory_limit|max_input_time|max_execution_time) *=' /etc/php/*/fpm/php.ini - Overrides in conf.d and pools
grep -rEn 'upload_max_filesize|post_max_size' /etc/php/*/fpm/conf.d/ /etc/php/*/fpm/pool.d/ - The nginx limit
nginx -T 2>/dev/null | grep -n 'client_max_body_size' - What does the web server return for a large body? (look at the status line)
curl -s -o /dev/null -w '%{http_code}\n' -X POST --data-binary @/etc/services https://example.com/upload.php
Fix
- Create a drop-in
/etc/php/<version>/fpm/conf.d/99-upload.iniwithupload_max_filesize = 64Mandpost_max_size = 72M. The second value must be larger than the first. - Make sure
memory_limitis not smaller thanpost_max_sizeif the application loads the file into memory. - In nginx set
client_max_body_size 72M;(inhttp,serveror the uploadlocation). - Restart the PHP-FPM service of your version and reload nginx:
nginx -t && systemctl reload nginx. - For slow connections also raise
max_input_timeandmax_execution_time.
Typical scenario
A user uploads a 20 MB PDF to the WordPress media library. You already raised upload_max_filesize to 64M, yet the upload fails, and the browser shows "413 Request Entity Too Large" instead of a PHP message. That error comes from nginx itself: client_max_body_size is at its default of 1 MB and stops the request before PHP sees it. Open the browser's developer tools, Network tab, and read the status code of the upload request.
FAQ
Why must post_max_size be bigger than upload_max_filesize?
The POST request contains the file plus form fields and encoding overhead. If it exceeds post_max_size, PHP drops the whole request body.
Does .htaccess help on nginx?
No. nginx ignores .htaccess. Use the php.ini drop-in, or php_admin_value in the pool file.
How do I check the PHP values that are really in effect?
Call phpinfo() through the web server and look for upload_max_filesize and post_max_size; the "Local Value" column applies. On the command line, php-fpm8.3 -i | grep -E 'upload_max|post_max' shows the FPM values, while php -i only concerns the CLI.
Why does WordPress show a different limit than my php.ini?
WordPress reports the smaller of upload_max_filesize and post_max_size. On a multisite installation there is also a separate limit in the network settings. In addition, client_max_body_size in nginx can limit the value further.
What else limits large uploads?
Besides size limits, time limits matter: max_input_time and max_execution_time in PHP, and fastcgi_read_timeout and client_body_timeout in nginx. On slow connections a large upload often fails on time, not size. max_file_uploads also caps the number of files per request.