Ffile2fix
Sign in Get started

Fix "The uploaded file exceeds the upload_max_filesize directive" in WordPress

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

PHP rejected the upload because the file is larger than upload_max_filesize allows, which defaults to 2M. WordPress reads this limit to show 'Maximum upload file size' in the media uploader. Raise upload_max_filesize and post_max_size together, and if you use Nginx, client_max_body_size as well.

Also appears as: backup.zip exceeds the maximum upload size for this site. · Maximum upload file size: 2 MB. · The link you followed has expired. · 413 Request Entity Too Large

Common causes

  • upload_max_filesize is left at the PHP default of 2M or a low host default
  • post_max_size is smaller than upload_max_filesize, so the whole request is discarded
  • Nginx client_max_body_size (default 1m) blocks the request first, returning 413
  • Settings changed in the wrong php.ini, or PHP-FPM not restarted after editing
  • A multisite network 'Max upload file size' setting lower than PHP's limit

How to fix it

  1. Check the current limits. Go to Tools > Site Health > Info > Server to see upload_max_filesize and post_max_size, or check phpinfo(). The media uploader shows the smaller effective limit.
  2. Raise the limits in php.ini. Set upload_max_filesize = 128M and post_max_size = 128M (post_max_size must be equal or larger) in the active php.ini, then restart PHP-FPM with sudo systemctl restart php8.3-fpm. On shared hosting use the control panel's PHP options or MultiPHP INI Editor.
  3. Use .user.ini or .htaccess on shared hosting. For PHP-FPM/CGI, create .user.ini in the WordPress root with the same two lines; changes apply after user_ini.cache_ttl (5 minutes by default). For Apache with mod_php, use php_value upload_max_filesize 128M in .htaccess instead.
  4. Raise the Nginx body size. Add client_max_body_size 128M; to the http, server or location block, test with sudo nginx -t, and reload with sudo systemctl reload nginx. Without it, Nginx returns 413 before PHP sees the file.
  5. Check multisite settings. On multisite, go to Network Admin > Settings and raise 'Max upload file size'. It cannot exceed PHP's limits.
  6. Upload very large files another way. For files larger than your host allows, upload them over SFTP to wp-content/uploads and register them with wp media import /path/to/file.zip.

php.ini / .user.ini and Nginx

; php.ini or .user.ini
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300

# nginx server block
client_max_body_size 128M;

How to stop it happening again

  • Set upload limits as part of your server provisioning, not after the first failure
  • Keep post_max_size equal to or larger than upload_max_filesize
  • Keep Nginx client_max_body_size in sync with PHP's upload limits
  • Compress or resize images before upload to stay well under the limit

Frequently asked questions

Why does adding the setting to wp-config.php not work?

upload_max_filesize and post_max_size are PHP_INI_PERDIR settings, so ini_set() in wp-config.php cannot change them. They must be set in php.ini, .user.ini, .htaccess (mod_php) or the PHP-FPM pool config.

Why do I get 'The link you followed has expired' instead?

That appears when the whole request exceeds post_max_size, so PHP discards the form data and WordPress's security check fails. Raising post_max_size fixes it.

What is a safe upload size?

Use the smallest limit that fits your largest legitimate file, such as 64M or 128M for most sites. Very large limits let a single request consume more memory, disk and time.