Ffile2fix
Sign in Get started

How to fix "The uploaded file exceeds upload_max_filesize"

The uploaded file exceeds the upload_max_filesize directive in php.ini.

PHP rejected the upload because the file is bigger than upload_max_filesize, which defaults to just 2M. The file never reaches your code. You need to raise upload_max_filesize and post_max_size together, and also the web server's body limit on Nginx.

Also appears as: photo.jpg exceeds the maximum upload size for this site. · UPLOAD_ERR_INI_SIZE ($_FILES['file']['error'] = 1) · 413 Request Entity Too Large (nginx) · The file "backup.zip" exceeds your upload_max_filesize ini directive (limit is 2048 KiB).

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

Frequently asked questions

Does memory_limit need to be larger than the upload?

No. PHP streams uploads to a temp file. memory_limit only matters if your code then loads the whole file into memory, for example for image processing.

Why does my .htaccess change cause a 500 error?

php_value only works with mod_php. On PHP-FPM or LiteSpeed in some modes, use .user.ini or the control panel instead.

I raised it but WordPress still shows the old limit. Why?

WordPress reads the smaller of upload_max_filesize and post_max_size. Check both values in phpinfo() and restart PHP-FPM.