How to Fix the "upload_max_filesize" Error in WordPress

intermediate📝 WordPress2026-04-02| WordPress (any version), PHP 7.4+, Apache or Nginx Web Server

Error Message

The uploaded file exceeds the upload_max_filesize directive in php.ini
#wordpress#php.ini#upload_max_filesize#server-config#devops

The ProblemYou’re ready to upload a new theme or a 15MB high-res hero image, but WordPress stops you cold. A red bar appears: The uploaded file exceeds the upload_max_filesize directive in php.ini. This isn't a bug in WordPress. It is a security ceiling set by your server’s PHP configuration to prevent massive files from overwhelming your storage.

Many hosting providers set a default limit of just 2MB or 8MB. Since modern page builders like Elementor or heavy plugins often exceed 20MB, you will likely hit this wall sooner rather than later.

Check Your Current LimitBefore you start digging into code, see exactly what your server allows. Head over to Media > Add New in your WordPress dashboard. Right below the upload box, look for the text: "Maximum upload file size: X MB."

If you prefer the command line, verify the limit by running this command:

php -i | grep upload_max_filesize

Alternatively, drop a file named info.php into your WordPress root folder containing <?php phpinfo(); ?>. Open yourdomain.com/info.php in your browser and search for upload_max_filesize and post_max_size. These two values must be adjusted together to fix the error.

How to Increase the Limit### 1. Edit the php.ini fileThis is the cleanest fix if you manage your own VPS or use a local setup like XAMPP. You need to find the active php.ini file. On a standard Ubuntu server running PHP 8.2, it’s usually found at /etc/php/8.2/fpm/php.ini.

Look for these specific lines and increase the numbers. For example, to allow 64MB files, use:

upload_max_filesize = 64M
post_max_size = 70M
memory_limit = 128M

Pro tip: Always make post_max_size slightly larger than upload_max_filesize. The "post" size includes the file plus any other form data sent in the request. After saving, restart your services to apply the changes:

# For Apache
sudo systemctl restart apache2

# For Nginx/PHP-FPM
sudo systemctl restart php8.2-fpm

2. Use the .htaccess file (Apache)If you are on shared hosting and can't access the main PHP config, the .htaccess file in your WordPress root directory is your best friend. Add these lines at the very bottom:

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value memory_limit 128M
php_value max_execution_time 300

Be careful: if your host uses FastCGI, this might trigger a "500 Internal Server Error." If your site breaks, simply remove those lines to restore access.

3. Update Nginx ConfigurationEven if you fix PHP, Nginx might still block the request with a "413 Request Entity Too Large" error. You must tell Nginx to allow larger uploads by editing your site’s configuration file (found in /etc/nginx/sites-available/):

server {
    ...
    client_max_body_size 64M;
    ...
}

Reload Nginx with sudo nginx -s reload to finish the job.

4. The wp-config.php MethodThis is a last-resort attempt. It rarely works on modern, secured hosts because upload_max_filesize is a system-level setting, but it’s worth a shot if you have no other options. Add this before the "That's all, stop editing" line:

@ini_set( 'upload_max_filesize' , '64M' );
@ini_set( 'post_max_size', '64M');

Summary of Best Practices- The Chain of Command: Your upload must pass through three gates: Nginx/Apache, then PHP, and finally WordPress. If any gate is too small, the upload fails.- Restart Everything: PHP settings are not dynamic. If you don't restart PHP-FPM or Apache, the server will continue using the old 2MB limit.- Contact Support: Some managed hosts lock these settings. If you’ve tried these steps and the limit in Media > Add New hasn't changed, ask your host to increase it for you.

Related Error Notes