The WordPress maximum upload size is set by PHP, not by WordPress. WordPress takes two PHP settings, upload_max_filesize and post_max_size, and uses whichever is smaller. To raise it, raise both in your hosting control panel’s PHP settings, with post_max_size equal to or a little above upload_max_filesize. On some servers you can set them in .htaccess or .user.ini instead. Adding ini_set() to wp-config.php does not work for these two settings.
This guide shows where WordPress reads the limit, why so many sites are stuck at 2 MB or 8 MB, which method works on which kind of server, and what we saw when we changed each setting on a test site.
Where does WordPress show the maximum upload size?
Go to Media, Add New Media File. Under the upload box WordPress prints a line such as “Maximum upload file size: 2 MB.” The same limit applies when you add an image inside the editor, upload a plugin or theme as a zip file, or import a file.
If you pick a file larger than the limit in the media uploader, WordPress stops it before uploading and shows “filename exceeds the maximum upload size for this site.”
Why is the WordPress upload limit 2 MB or 8 MB?
Those are PHP’s own defaults. The PHP manual’s list of core php.ini settings gives upload_max_filesize a default of 2M and post_max_size a default of 8M. The sample php.ini files that ship with PHP use the same two values.
We set up a fresh WordPress 7.1.4 site on the official WordPress Docker image with PHP 8.3, which ships with no php.ini of its own and so runs on PHP’s defaults. The media screen said “Maximum upload file size: 2 MB.” If your new site shows 2 MB, nobody has changed PHP’s settings yet. If it shows 8 MB, someone raised upload_max_filesize but left post_max_size at its default.
How does WordPress work out the upload limit?
The function that does it is wp_max_upload_size(). We read it in the WordPress 7.1.4 source. It reads both PHP settings, converts them to bytes, and returns the smaller one. A plugin can change the number through a filter called upload_size_limit, which we come back to below.
Then we changed the two PHP settings on the test site, restarted PHP, and read the media screen each time:
- upload_max_filesize 64M, post_max_size left at 8M. The screen said 8 MB.
- upload_max_filesize left at 2M, post_max_size 64M. The screen said 2 MB.
- upload_max_filesize 64M, post_max_size 32M. The screen said 32 MB.
- Both set to 64M. The screen said 64 MB, and a 3.3 MB image that had failed before uploaded.
Raising only one setting is the most common reason a change “does not work”. Always change both.
On a WordPress multisite network there is a third limit. In the source, multisite also caps uploads at the network’s “Max upload file size” setting, which defaults to 1,500 KB, and at the site’s remaining storage space. You change that one under Network Admin, Settings.
How do you raise the upload limit on your hosting?
Which method works depends on how your server runs PHP. Try them in this order.
How do you change it in cPanel?
cPanel has a screen called MultiPHP INI Editor, described in cPanel’s documentation. The documentation notes that your host can turn this screen off, so it may not be on every plan.
- Log in to cPanel and open MultiPHP INI Editor.
- In Basic Mode, choose the domain of your WordPress site, or your home directory to change every site on the account.
- Set
upload_max_filesizeandpost_max_size. For example, 64M and 64M. - Click Apply.
- Reload Media, Add New Media File in WordPress and read the new limit.
According to cPanel’s documentation, the editor writes the values to php.ini, .user.ini and .htaccess, wherever each file supports them. On servers that use LiteSpeed’s PHP module, it adds them to .htaccess inside an lsapi_module section. So if you edit those files by hand later, you may find these lines already there.
Does .htaccess work for the upload limit?
Only when the web server reads PHP settings from .htaccess. That is true when PHP runs as an Apache module, and cPanel’s documentation shows the same lines in .htaccess for LiteSpeed’s PHP module. Add these two lines at the end of the .htaccess file in your WordPress folder:
php_value upload_max_filesize 64M
php_value post_max_size 64M
On our test site, which runs PHP as an Apache module, these two lines took the limit from 2 MB to 64 MB, and removing them brought it back to 2 MB.
Be careful on other setups. When the web server does not recognise a line in .htaccess, it can refuse every request. On our test site, one unrecognised line in .htaccess turned every page into a “500 Internal Server Error”. If that happens after you add these lines, remove them and use one of the other methods.
When should you use a .user.ini file?
When PHP runs as CGI or FastCGI, which includes PHP-FPM. The PHP manual’s page on .user.ini files says PHP reads them only in that mode, and says to use .htaccess instead if PHP runs as an Apache module. Create a file named .user.ini in your WordPress folder with:
upload_max_filesize = 64M
post_max_size = 64M
The same page says PHP re-reads .user.ini files every 300 seconds by default. If nothing changes straight away, wait five minutes before you try something else.
What if you run your own server?
On a VPS, put the two settings in the php.ini file for the PHP version your site uses, or in a file in its conf.d folder, then restart PHP or the web server. That is what we did on the test site. Settings in php.ini only take effect after the restart.
Why doesn’t changing wp-config.php or functions.php work?
Many guides suggest adding @ini_set( 'upload_max_filesize', '64M' ); to wp-config.php or to a theme’s functions.php. We added that line, and the same for post_max_size, to the top of wp-config.php on the test site. The media screen still said 2 MB.
The PHP manual explains why. Both settings are marked INI_PERDIR, which means they can be set in php.ini, .htaccess, httpd.conf or .user.ini, but not by ini_set() from inside a script. PHP reads them before WordPress starts. By the time wp-config.php runs, it is too late.
Do upload size plugins work?
Some plugins and code snippets use the upload_size_limit filter, which changes the number WordPress shows. That number is not what PHP enforces. We tested it with a three-line plugin that sets the filter to 64 MB while PHP stayed at its defaults:
- The media screen said “Maximum upload file size: 64 MB.”
- Uploading a 3.3 MB image failed with “The uploaded file exceeds the upload_max_filesize directive in php.ini.”
A plugin can lower the limit that way, but it cannot raise it above what PHP allows. Before you install one, look at what it does. If it only changes the number on the screen, it will not help.
What else can stop a large upload?
- Memory. The PHP manual says
memory_limitshould generally be larger thanpost_max_size. PHP’s default memory limit is 128M. WordPress also needs memory to make the smaller image sizes from a large photo. - Time. A large file on a slow connection can take longer than the server allows. The sample php.ini files that ship with PHP set
max_execution_timeto 30 seconds andmax_input_timeto 60 seconds. Your host’s values may differ. - The web server. The web server in front of PHP can have its own limit on request size. If PHP’s settings are right and big uploads still fail, ask your host.
- Disk space. An upload fails if your hosting account is full. Our guide on how much storage a WordPress site needs shows how big a site grows.
What upload size should you set?
Set it a little above the largest file you actually upload. Check the size of your biggest photo, PDF or plugin zip, and choose the next round number above it, such as 32M or 64M. Video files are usually far larger, and are better hosted on a video service and embedded.
Large images make pages heavier for visitors. In the source, when an uploaded image is wider or taller than 2560 pixels, WordPress keeps the original and makes a scaled copy to use on the site. Resize photos before you upload them where you can.
If you have just set up a site with our guide to installing WordPress, the limit you see comes from your host’s PHP settings, so check it before you upload your first large file. If you are choosing hosting, our WordPress hosting page explains what the plans include.
Frequently asked questions
Why is my WordPress maximum upload size only 2 MB?
Because PHP’s default upload_max_filesize is 2M, and WordPress uses the smaller of that and post_max_size. Raise both in your hosting control panel’s PHP settings.
Can I increase the upload size in wp-config.php?
No. upload_max_filesize and post_max_size cannot be changed with ini_set(), so a line in wp-config.php has no effect. We tested it, and the limit stayed at 2 MB.
I changed upload_max_filesize but the limit is still 8 MB. Why?
post_max_size is still at its default of 8M, and WordPress uses the smaller of the two. Set post_max_size to the same value or higher.
Should I use .htaccess or .user.ini?
Use .htaccess when PHP runs as an Apache module, and .user.ini when it runs as CGI or FastCGI. If you do not know which, use your hosting control panel’s PHP settings, which write to the right file.
How long does it take for a new upload limit to work?
Changes in .htaccess work on the next page load. PHP re-reads .user.ini every five minutes by default. Changes in php.ini need a PHP restart.
