WordPress rejects a plugin or media upload: exceeds the upload_max_filesize directive in php.ini
The uploaded file exceeds the upload_max_filesize directive in php.ini.Short answer
WordPress takes its upload limit from PHP: the smaller of upload_max_filesize and post_max_size. Both are per-directory settings, so ini_set() in wp-config.php cannot raise them. Set them in php.ini or the PHP-FPM pool, in .user.ini for CGI or FastCGI, or with php_value in .htaccess for the Apache module.
Fix it fast
1Find out which cause you have
Find out what PHP itself reports for the WordPress site. Put a temporary phpinfo() page in the WordPress folder, open it in the browser, search it for upload_max_filesize, post_max_size and the server API, then delete the file.
<?php // limits.php in the WordPress folder; delete it after use phpinfo();2Match what you see, then jump to its fix
- 1
phpinfo shows upload_max_filesize at 2M, or a post_max_size lower than the file you uploadupload_max_filesize or post_max_size is smaller than the fileFix - 2
You added ini_set('upload_max_filesize', ...) and the value in phpinfo did not moveAn ini_set() call in wp-config.php, a theme or a plugin tries to raise the limitFix - 3
The file contains the new numbers, but phpinfo still shows the old ones.user.ini or .htaccess was edited for the wrong way of running PHP, or PHP has not re-read itFix - 4
Your changes in .htaccess or through ini_set() never show in phpinfo, even after a restartThe host or the pool pins the value with php_admin_valueFix
- 1
What does the error look like?
The uploaded file exceeds the upload_max_filesize directive in php.ini.
Cause 1 of 4
upload_max_filesize or post_max_size is smaller than the file
1Check
WordPress computes its upload limit as the smaller of the two PHP values, and plugins can change it again through the upload_size_limit filter. upload_max_filesize defaults to 2M, and the manual says post_max_size must be larger than it.
<?php
echo 'upload_max_filesize=', ini_get('upload_max_filesize'), ' post_max_size=', ini_get('post_max_size'), "\n";2Fix
Raise both values in the main configuration, with post_max_size a little above upload_max_filesize. Use php.ini, or the pool file if you run PHP-FPM. Reload PHP afterwards.
; php.ini
upload_max_filesize = 64M
post_max_size = 72M
; or in the PHP-FPM pool file
php_admin_value[upload_max_filesize] = 64M
php_admin_value[post_max_size] = 72M
# then, in a shell
sudo systemctl reload php8.3-fpm3Verify
Reload the phpinfo page. Both values show the new numbers, and the plugin upload that failed now goes through.
curl -s https://example.com/limits.php | grep -i -E "upload_max_filesize|post_max_size"Confirmed by php.net
Cause 2 of 4
An ini_set() call in wp-config.php, a theme or a plugin tries to raise the limit
1Check
upload_max_filesize and post_max_size can be changed in php.ini, .htaccess, httpd.conf and .user.ini, but not from a script: the manual lists them as per-directory settings, and only user-level settings can be changed with ini_set().
grep -rn -E "ini_set\(.(upload_max_filesize|post_max_size)" wp-config.php wp-content/ | head -n 202Fix
Delete those ini_set() lines, because they cannot work, and set the values where the manual allows it: the other causes show where.
// wp-config.php: remove lines like these
// ini_set('upload_max_filesize', '64M');
// ini_set('post_max_size', '72M');3Verify
The grep finds nothing, and the limit comes from the file you changed instead.
grep -rn -E "ini_set\(.(upload_max_filesize|post_max_size)" wp-config.php wp-content/ | head -n 20Confirmed by php.net
Cause 3 of 4
.user.ini or .htaccess was edited for the wrong way of running PHP, or PHP has not re-read it
1Check
A .user.ini file is read only when PHP runs as CGI or FastCGI. PHP looks for it in the folder of the requested script and in each folder up to the document root, and it re-reads these files only every 300 seconds by default. php_value lines in .htaccess are the equivalent for PHP as an Apache module. Check the server API in phpinfo.
ls -la .user.ini .htaccess2Fix
Use the file that matches the server API: .user.ini for CGI or FastCGI, php_value in .htaccess for the Apache module. Put it in the WordPress folder, then wait up to five minutes for PHP to re-read it.
; .user.ini in the WordPress folder (CGI or FastCGI)
upload_max_filesize = 64M
post_max_size = 72M
# .htaccess (PHP as an Apache module only)
php_value upload_max_filesize 64M
php_value post_max_size 72M3Verify
After the cache time, reload the phpinfo page: the new values show up.
curl -s https://example.com/limits.php | grep -i -E "upload_max_filesize|post_max_size"Confirmed by php.net
Cause 4 of 4
The host or the pool pins the value with php_admin_value
1Check
A directive set with php_admin_value cannot be overridden by .htaccess or ini_set(), and in a PHP-FPM pool file it cannot be overridden by ini_set(). Search the Apache and PHP-FPM configuration for it.
grep -R -n -E "php_admin_value.*(upload_max_filesize|post_max_size)" /etc/apache2 /etc/httpd /etc/php 2>/dev/null2Fix
Change the value in the file that pins it, or ask the hosting provider to do so if you cannot edit it yourself. Reload the service afterwards.
; pool file found by the grep
php_admin_value[upload_max_filesize] = 64M
php_admin_value[post_max_size] = 72M3Verify
Reload PHP and open the phpinfo page again; the new numbers show.
sudo systemctl reload php8.3-fpm
curl -s https://example.com/limits.php | grep -i -E "upload_max_filesize|post_max_size"Confirmed by php.net
How do I stop it coming back?
- Keep post_max_size above upload_max_filesize, and memory_limit above both.
- Edit the setting once, in the place that matches how PHP runs, and remove old attempts from wp-config.php, .htaccess and .user.ini.
- Delete the phpinfo page as soon as you have read it; it shows server details to anyone who opens it.
Sources
- PHP manual: core php.ini directives (upload_max_filesize, post_max_size)
- PHP manual: where a configuration setting may be set
- PHP manual: .user.ini files
- PHP manual: how to change configuration settings (Apache, php_admin_value)
- PHP manual: FPM configuration (pool php_admin_value)
- WordPress developer reference: wp_max_upload_size()
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
A PHP upload fails or $_FILES comes back empty
$_POST and $_FILES are both empty on a large upload
A PHP upload fails for one of four reasons: the temporary directory is not writable, the whole POST is bigger than post_max_size, one file is bigger than upload_max_filesize, or there are more files than max_file_uploads.
4 causes, each with a fixServers
WordPress in Docker keeps the old upload size limit
413 Request Entity Too Large
The wordpress image runs stock PHP, whose default upload limit is 2M with an 8M POST cap.
3 causes, each with a fixBack end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fix