How to Fix 'The uploaded file exceeds the upload_max_filesize directive' in WordPress

Learn how to easily fix the upload_max_filesize directive error in WordPress. A technical guide on modifying php.ini, .htaccess, and wp-config.php to increase PHP upload limits.

How to Fix 'The uploaded file exceeds the upload_max_filesize directive' in WordPress

One of the most common—and arguably most frustrating—errors you will encounter when setting up a new WordPress website occurs right when you try to upload a premium theme or a heavy backup plugin.

Instead of a success message, WordPress aggressively throws a long, highly technical warning: “The uploaded file exceeds the upload_max_filesize directive in php.ini.”

Despite appearing inside the WordPress dashboard, this is not a WordPress error. This is a fundamental server-level restriction. By default, PHP (the programming language that powers WordPress) is shipped with extremely conservative security settings, often limiting file uploads to a mere 2MB or 8MB to prevent server flooding. If you attempt to upload a 30MB Divi Theme zip file, PHP will instantly reject it.

This issue is a close cousin to the Memory Exhausted Error, as both are caused by PHP’s strict resource limitations. Here is exactly how to override these directives and increase your upload capacity.

If your web host provides cPanel, you do not need to touch any code. You can visually override the default php.ini file using a built-in graphical tool.

  1. Log into your cPanel account.
  2. Scroll down to the Software section and click on MultiPHP INI Editor.
  3. Select your WordPress website’s domain name from the dropdown menu.
  4. Scroll down until you find upload_max_filesize. Change the value from 2M to 256M.
  5. Locate post_max_size. This value dictates the maximum size of the entire HTTP POST request. It must be equal to or greater than the upload max filesize. Change it to 256M.
  6. (Optional but recommended) Increase max_execution_time to 300 seconds so that heavy uploads don’t time out halfway through.
  7. Click Apply.

Go back to WordPress and refresh the page. Your upload limit should now successfully reflect 256MB.

2. Override via the .htaccess File

If you are using a host without a visual PHP editor, but your server is running Apache or LiteSpeed, you can force the PHP directives to change by injecting code into your website’s hidden .htaccess file. (Note: This file is also heavily involved in resolving HTTP Image Upload Errors).

  1. Open your File Manager or connect via FTP.
  2. Navigate to your public_html (root) directory.
  3. Make sure “Show Hidden Files” is enabled, and edit the .htaccess file.
  4. Paste the following snippet at the very bottom of the file:
php_value upload_max_filesize 256M
php_value post_max_size 256M
php_value max_execution_time 300
php_value max_input_time 300

Save the file. This will explicitly instruct the server environment to process larger files for your specific directory.

3. Fallback: Override via wp-config.php

If .htaccess is ignored (which is common on Nginx servers), you can try telling WordPress to inject the PHP limits at runtime using the core configuration file.

  1. Open your File Manager.
  2. Edit the wp-config.php file located in the root directory.
  3. Scroll down until you find the line that says /* That's all, stop editing! Happy publishing. */.
  4. Above that line, paste the following PHP code:
@ini_set( 'upload_max_size' , '256M' );
@ini_set( 'post_max_size', '256M');
@ini_set( 'max_execution_time', '300' );

Save the changes.

Stop Fighting Restrictive Hosting Environments

If you have tried all three of the technical methods above and the error still persists, you are unfortunately dealing with a restrictive, hard-coded hosting environment. Many budget shared hosts actively lock down php.ini directives at the root level, making it literally impossible for you to increase your upload sizes, forcing you to upload everything manually via FTP.

This is a terrible workflow. With Nextgen’s WordPress Hosting in Pakistan, we put the power back in the developer’s hands. Our flexible LiteSpeed environment grants you full, unrestricted access to modify your own PHP variables. Whether you need to upload a 5MB PDF or a massive 1GB complete site backup archive, our servers give you the absolute freedom to configure your resources exactly as you see fit.

Increase your upload limits without touching php.ini via modern Shared Hosting.