Fix the PHP upload_max_filesize Error in WordPress

If WordPress displays “The uploaded file exceeds the upload_max_filesize directive in php.ini”, PHP is rejecting the upload because the file is larger than the configured limit. The fix is to change the PHP upload settings used by your website, then check any additional limits imposed by WordPress, your web server, or your hosting provider.

The correct method depends on your hosting setup. Use your host's PHP settings editor when available; otherwise, ask your hosting provider which configuration file applies to your domain. Editing a theme's functions.php file will not reliably change PHP upload limits.

What causes the upload_max_filesize error?

The uploaded file exceeds the upload_max_filesize directive in php.ini.

PHP upload max file size error message

PHP controls the maximum size of an individual uploaded file with upload_max_filesize. The post_max_size setting controls the maximum size of the entire request and should be larger than upload_max_filesize. Other limits may also apply, so raising one value alone may not solve every upload problem.

Method 1: Change PHP settings in your hosting control panel

This is usually the easiest option on shared hosting.

  1. Sign in to your hosting control panel.
  2. Look for a tool named MultiPHP INI Editor, PHP Settings, or a similar PHP configuration editor.
  3. Select the correct domain or PHP version, then set values appropriate for the files you need to upload.
  4. Save the settings and retry the upload.

For example, if your host permits it, you might use:

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 128M
max_execution_time = 120
max_input_time = 120

These are example values, not universal recommendations. Choose limits that suit your site's needs and your hosting plan. Keep post_max_size greater than upload_max_filesize. Your provider may enforce maximum values or use a different settings interface.

Method 2: Use a supported php.ini or user.ini file

On some VPS or dedicated servers, you can edit the PHP configuration file for the PHP version and handler used by your website. On certain PHP-FPM or CGI setups, a per-directory .user.ini file may be supported instead. The correct file path and whether local overrides are enabled vary by host.

  1. Confirm which PHP version and handler your site uses.
  2. Ask your hosting provider or check the server's PHP configuration to identify the correct configuration file.
  3. Change the required directives, using values appropriate for your site. For example:
upload_max_filesize = 20M
post_max_size = 25M

Save the file and follow your host's instructions for applying the change. Editing the wrong php.ini may have no effect because the website could be using a different PHP configuration. PHP-FPM services may require a reload or restart by an administrator; shared hosting users should not restart services themselves.

Method 3: Check web-server upload limits

If PHP's limits are high enough but uploads still fail, your web server or hosting platform may impose another request-size limit.

  • Nginx: An administrator may need to review the applicable client_max_body_size directive in the server or location configuration.
  • Apache: Server rules or hosting restrictions may limit request sizes, depending on the configuration.
  • Managed hosting or a security layer: Provider-level limits may apply even when your PHP settings appear correct.

If you do not manage the server configuration, contact your host rather than editing server files you cannot safely validate.

Why editing .htaccess may not work

Some older Apache PHP configurations accepted directives such as php_value upload_max_filesize in .htaccess. These directives are not supported in every PHP handler and can trigger an HTTP 500 error when used with incompatible setups, including many PHP-FPM configurations. Do not add them unless your host specifically confirms that your server supports them.

Why functions.php is not the fix

Adding ini_set() calls to a WordPress theme's functions.php file is not a reliable way to increase upload limits. The settings may be restricted by the host, and upload_max_filesize and post_max_size are PHP configuration directives that cannot generally be raised this way after the request has started. Avoid editing the theme to solve this error.

Verify the active upload limits

  1. Open WordPress and check Tools → Site Health → Info, then look for the Media Handling or server-related information available in your version.
  2. Compare the reported limits with the settings you intended to change. Your hosting control panel may also show the active values.
  3. Retry the upload. If the error remains, check the exact file size and ask your host whether another PHP, web-server, or platform limit applies.

Do not leave a public phpinfo() file on your website; it can expose server configuration details. If you create a temporary diagnostic file, restrict access and remove it immediately after use.

Frequently asked questions

What should upload_max_filesize and post_max_size be?

Set upload_max_filesize high enough for the largest file you need to upload. Set post_max_size higher than that so the complete request can fit. The appropriate values depend on your site's needs and hosting limits.

Can I change the upload limit from WordPress functions.php?

Not reliably. PHP upload directives are generally configured before WordPress runs. Use your hosting control panel or the PHP configuration method supported by your host.

Why does changing php.ini not affect WordPress?

Your website may use a different PHP version, handler, or configuration file, or the host may disallow local overrides. Confirm which PHP configuration applies to the domain with your hosting provider.

What if the PHP limit is already high enough?

Check the web server's request-size limit, managed-hosting restrictions, and the actual file size. On Nginx, for example, an administrator may need to review client_max_body_size.