Common causes
- upload_max_filesize is still at the 2M default
- post_max_size is lower than or equal to upload_max_filesize
- Nginx client_max_body_size is smaller than the file (returns 413 before PHP)
- Settings changed in the wrong php.ini or PHP-FPM was not restarted
- Shared hosting caps the value at the account level
- A .htaccess php_value line on a server running PHP-FPM, where it is ignored or causes a 500 error
How to fix it
- Check the active values. Open phpinfo() and look for upload_max_filesize, post_max_size and Loaded Configuration File. Edit that exact file or add a .user.ini in your web root.
- Raise both PHP limits. Set upload_max_filesize = 64M and post_max_size = 72M. post_max_size must be larger than upload_max_filesize because the request also contains other form data.
- Restart PHP. Run sudo systemctl restart php8.3-fpm (or restart Apache for mod_php). .user.ini changes are picked up after user_ini.cache_ttl, 5 minutes by default.
- Raise the Nginx limit. Add client_max_body_size 72M; to the http, server or location block, then run nginx -t and reload. Without this Nginx returns 413 before PHP sees the file.
- Use the host's control panel. On cPanel use MultiPHP INI Editor or Select PHP Version > Options. Some hosts set a maximum you cannot exceed; ask support or upload large files by SFTP instead.
php.ini and Nginx settings for 64 MB uploads
; php.ini or .user.ini
upload_max_filesize = 64M
post_max_size = 72M
memory_limit = 256M
# nginx server block
client_max_body_size 72M; How to stop it happening again
- Keep post_max_size slightly larger than upload_max_filesize
- Document upload limits for every layer (CDN, Nginx, PHP, app)
- Use chunked uploads for very large files
- Re-check limits after PHP version upgrades, which use a new php.ini