Blog / WordPress/ Fixing WordPress File Upload Size Limit Errors: Three Main Solutions Explained

Fixing WordPress File Upload Size Limit Errors: Three Main Solutions Explained

When uploading media files in the WordPress admin area, encountering a "file exceeds the size limit" error is typically due to server PHP configuration limits on upload file size, POST data size, or script execution time. This article systematically details three mainstream and effective solutions to permanently resolve this issue.

Solution Overview

Resolving WordPress upload limits centers on modifying PHP runtime configuration. There are three primary approaches, which you can choose based on your server control level and familiarity:

  • Modify the WordPress Theme Functions File: The most convenient and least invasive method.
  • Modify Server Configuration Files (.htaccess or php.ini): The most thorough effect, but requires corresponding server support.
  • Modify via Hosting Control Panel: The most intuitive method, suitable for users of panels like cPanel or Plesk.

Method 1: Modify the WordPress Theme Functions File (Recommended)

This is the safest and most convenient method, requiring no direct server file edits, with changes taking effect with the theme. Add the following code to the end of your active theme's functions.php file.

// Increase WordPress upload limits
@ini_set('upload_max_filesize', '64M');
@ini_set('post_max_size', '64M');
@ini_set('max_execution_time', '300');
@ini_set('max_input_time', '300');

Parameter Explanation:

  • upload_max_filesize: Maximum allowed size for a single uploaded file.
  • post_max_size: Maximum amount of data that can be submitted via a POST request (must be greater than or equal to upload_max_filesize).
  • max_execution_time: Maximum script execution time in seconds; larger files require more time.
  • max_input_time: Maximum time in seconds for parsing input data (e.g., POST data).

Advantages: Simple operation, does not affect other sites on the server.
Note: This method may fail if the relevant parameters in the server's main configuration are set too low.

Method 2: Modify Server Configuration Files

This method directly modifies the server's PHP configuration, applying changes globally and thoroughly. The procedure differs based on your server type (Apache or Nginx).

For Apache Servers (Using .htaccess)

If your site runs on Apache and supports PHP configuration override via .htaccess, add the following code to the .htaccess file in your WordPress root directory, before the "# BEGIN WordPress" rules:

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

Important: Ensure this is placed outside WordPress's own rewrite rules, typically at the file's top or before the # BEGIN WordPress comment, to avoid rule conflicts.

For Nginx Servers

Nginx does not support .htaccess or the php_value directive. You must directly modify the server's PHP configuration file (usually php.ini) or the site's Nginx virtual host configuration.

  1. Locate the php.ini file: Check the "Loaded Configuration File" path via a phpinfo() file.
  2. Edit php.ini: Find and modify these parameters:
    upload_max_filesize = 64M
    post_max_size = 64M
    max_execution_time = 300
    max_input_time = 300
  3. Restart PHP Service: After saving, restart PHP-FPM or the web server (e.g., Nginx) for changes to take effect.

Method 3: Modify via Hosting Control Panel (e.g., cPanel)

For users of graphical control panels like cPanel or Plesk, this is the most intuitive method.

  1. Log into your control panel and navigate to the PHP configuration or settings for your website.
  2. Locate the option to modify PHP settings or edit php.ini values.
  3. Find and adjust the following parameters:
    upload_max_filesize = 64M
    post_max_size = 64M
    max_execution_time = 300
    max_input_time = 300
  4. Save the changes and restart the PHP service if required.

Troubleshooting & Important Notes

  • Check Order: Try solutions in the order "Method 1 → Method 3/Method 2", prioritizing the least invasive option.
  • Parameter Consistency: Ensure post_max_size is greater than or equal to upload_max_filesize.
  • Unit Note: "M" in the configuration stands for Megabytes; use uppercase.
  • Still Not Working? If none of the above works, your hosting provider may enforce a hard limit at a higher level. Contact their support to request an increase.
  • Security Reminder: Excessively high max_execution_time and file size limits can pose security risks. Set reasonable values based on actual needs.

Using any of the above methods, you can effectively resolve WordPress file upload size limit errors. Choose the method best suited to your operational environment.