---
title: "Fix \"exceeds the upload_max_filesize directive\" in WordPress"
url: https://wpministry.co/errors/upload-max-filesize/
description: "PHP refused a file larger than upload_max_filesize. Raise it and post_max_size together, in .htaccess, .user.ini or the host's PHP settings. Nothing is lost."
lang: en-US
---

Skip to content

# How to fix "The uploaded file exceeds the upload_max_filesize directive in php.ini" in WordPress

PHP refused a file larger than its upload_max_filesize setting, and WordPress passed the message on. Raise upload_max_filesize and post_max_size together, in .htaccess, in .user.ini or in your host's PHP settings, depending on how PHP runs. Nothing on the site has been lost.

By

WP Ministry

Published

October 7, 2026

Tested on

WordPress 7.1.4, PHP 8.3.36

## In short

- Nothing is lost. The server refused one file, and the site is as it was.
- The figure under Media, Add Media File is the limit you are under.
- Two PHP settings decide it, upload_max_filesize and post_max_size. Raise both.
- An ini_set() line in wp-config.php changes neither of them.
- .htaccess works where PHP is part of Apache, and .user.ini where it runs as FPM or CGI.
- One large file can go in over SFTP and be added to the Media Library with WP-CLI.

PHP, the language WordPress runs on, refuses any uploaded file larger than its `upload_max_filesize` setting. WordPress then gives PHP's reason word for word: "The uploaded file exceeds the upload_max_filesize directive in php.ini." You meet it when you install a plugin or a theme from a .zip file, or add a file to the Media Library.

Nothing has been lost or changed. The server turned the file away before WordPress did anything with it, so the site is as it was a minute ago. To get the file in, raise the limit or bring the file in another way.

## Other messages from the same limit

The Media Library's own uploader is told the limit in advance. It stops a larger file in your browser and says that the file "exceeds the maximum upload size for this site." The limit is the same one, and so are the fixes.

The message on this page appears where nothing checks first: under Plugins, Add Plugin, Upload Plugin, when you upload a theme, in the Media Library's browser uploader, and when something has told WordPress a higher figure than PHP allows.

WordPress keeps the message in a list of what can go wrong with an upload. Three of its neighbors are "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.", "The uploaded file was only partially uploaded." and "Missing a temporary folder." (https://wpministry.co/errors/missing-a-temporary-folder/) Those have other causes, and the fixes here do not clear them.

Two more are easy to take for this one. A file larger than PHP's second limit, `post_max_size`, makes a plugin upload fail with "The link you followed has expired." (https://wpministry.co/errors/are-you-sure-you-want-to-do-this/) On nginx, a request larger than `client_max_body_size` is answered "413 Request Entity Too Large" (https://wpministry.co/errors/413-request-entity-too-large/) before PHP sees the upload. The nginx server block generator (https://wpministry.co/tools/nginx-config-generator/) writes that setting into the server block it builds.

## See the limit you are under

Go to Media, then Add Media File. Under the upload box WordPress prints the limit, for example "Maximum upload file size: 2 MB." It is the smaller of two PHP settings: `upload_max_filesize`, the largest single file, and `post_max_size`, the largest form, files included. PHP's own defaults are 2M and 8M.

To see both, go to Tools, then Site Health, and open the Info tab. The "Media Handling" section lists "Max size of an uploaded file", "Max size of post data allowed" and "Max effective file size". The "Server" section has "PHP SAPI", which says how PHP runs on your server, and so which fix is yours:

- `apache2handler`: PHP is part of Apache. Use the `.htaccess` fix.
- `fpm-fcgi` or `cgi-fcgi`: PHP runs as FPM or CGI. Use the `.user.ini` fix.
- Anything else: use your host's PHP settings.

## Where it goes wrong

A page request passes through each of these in turn. This one comes from **PHP, the language WordPress runs on**.

1. Browser
2. DNS
3. HTTPS
4. CDN or firewall
5. Web server
6. PHP (this error comes from here)
7. WordPress
8. Database and files

## What causes it

- ### PHP's upload limit is lower than the file
  Common
  PHP accepts no uploaded file larger than upload_max_filesize. Its own default is 2M, which a plugin's .zip file, a video or a long PDF soon passes.
  Fix: Raise the limits in .htaccess, or Raise the limits in .user.ini, or Change it in your host's PHP settings, or Bring one large file in without the upload form
- ### The limit was raised somewhere PHP does not read
  Common
  These settings can be set in PHP's own configuration, in .htaccess or in .user.ini, and each of the last two is read only one way of running PHP. A line in wp-config.php or in a theme's functions.php changes nothing.
  Fix: Raise the limits in .htaccess, or Raise the limits in .user.ini
- ### The host fixes the limit for your plan
  Sometimes
  A host can set the limit in the server's configuration in a way that no file in your site can override. Then only the host can raise it.
  Fix: Change it in your host's PHP settings, or Ask the host to raise it, or Bring one large file in without the upload form

## How to fix it

### Raise the limits in .htaccess

- Takes care
- Back up first
- About 10 minutes
- Steps tested on WordPress 7.1.4

This works where PHP runs as part of Apache. Where PHP runs another way, the lines are skipped and nothing changes.

1. #### Step 1: Open .htaccess
   It is in the site's main folder, beside `wp-config.php`. Its name begins with a dot, so set your file manager to show hidden files if you cannot see it.
2. #### Step 2: Add these lines above "# BEGIN WordPress"
   Choose a figure with room above your largest file, and raise the two together. Never leave `post_max_size` below `upload_max_filesize`: the form carries the file and a little more. The first and last lines tell a server that runs PHP another way to skip the two in the middle instead of failing on them.
   .htaccess Copy

   ```
   <IfModule mod_php.c>
   php_value upload_max_filesize 64M
   php_value post_max_size 64M
   </IfModule>
   ```

3. #### Step 3: Reload Media, then Add Media File
   The figure now reads "Maximum upload file size: 64 MB." Upload the file again.

If the figure has not moved, PHP does not take settings from `.htaccess` on your server. Remove the lines and use the next fix. If you would rather not edit the file by hand, the .htaccess generator (https://wpministry.co/tools/htaccess-generator/) gives you a complete `.htaccess` with these lines above WordPress's own block, built in your browser.

**To undo it:** Remove the four lines from .htaccess.

### Raise the limits in .user.ini

- Easy
- Low risk
- About 10 minutes

Where PHP runs as FPM or CGI, it reads settings from a file named `.user.ini`. PHP as part of Apache never reads that file.

1. #### Step 1: Open or create .user.ini in the site's main folder
   If the file is there already, keep what it holds.
2. #### Step 2: Add these two lines
   .user.ini Copy

   ```
   upload_max_filesize = 64M
   post_max_size = 64M
   ```

3. #### Step 3: Wait five minutes, then reload Media, then Add Media File
   By default PHP looks at `.user.ini` again only every 300 seconds, so the change does not show at once. When the figure has gone up, upload the file again.

If the figure has not moved after ten minutes, the file is not being read, or the host does not let it change these settings. Use the host's own settings instead.

**To undo it:** Remove the two lines from .user.ini.

### Change it in your host's PHP settings

- Easy
- Low risk
- About 10 minutes
1. #### Step 1: Find the PHP settings page in your hosting panel
   Many hosts have one, under a name such as "PHP settings" or "PHP options".
2. #### Step 2: Set upload_max_filesize and post_max_size
   Give both a figure larger than your file, and save. If the page will not go as high as you need, that ceiling belongs to your plan.
3. #### Step 3: Reload Media, then Add Media File
   Check the figure, then upload the file again.

### Ask the host to raise it

- Easy
- No risk
- About 15 minutes

A host can set the limit where no file of yours overrides it. Then nothing above changes the figure, and only the host can.

1. #### Step 1: Write to support
   Give the size of the file. Ask them to set `upload_max_filesize` and `post_max_size` above it for your site, and whether your plan allows it.
2. #### Step 2: Send what Site Health shows
   Copy the two figures and "PHP SAPI" from Tools, Site Health, Info, so that they see what you see.

### Bring one large file in without the upload form

- Takes care
- Low risk
- About 15 minutes
- Steps tested on WordPress 7.1.4

The limit applies to what a browser sends through a form. A file that reaches the server over SFTP is not held to it.

For a plugin or a theme, unzip it and upload its folder, as the page on "The link you followed has expired." (https://wpministry.co/errors/are-you-sure-you-want-to-do-this/) describes. A file for the Media Library needs one more step, because the library lists only the files WordPress has a record of. WP-CLI makes that record. It needs SSH access to the server: how to use WP-CLI (https://wpministry.co/blog/use-wp-cli-manage-wordpress/) covers getting started.

1. #### Step 1: Upload the file over SFTP
   Put it in a folder of its own on the server, such as `incoming` in your home folder.
2. #### Step 2: Import it
   In the folder WordPress is installed in, run this with the path to your own file.
   WP-CLI answers "Success: Imported 1 of 1 items." and the file is in the Media Library.
   bash Copy

   ```
   wp media import ~/incoming/large-video.mp4
   ```

3. #### Step 3: Delete the copy you uploaded
   The import copies the file into WordPress's uploads folder, so the one in `incoming` is no longer needed.

**To undo it:** Delete the file from the Media Library.

## When to get help

If the figure under Media, Add Media File stays where it is whatever you change, the limit is set above anything you can reach, and only the host can move it. If the host will not, and large files are part of how the site works, the real question is which hosting the site needs, and that is worth a second opinion before you pay to move.

## Common questions

I raised the limit, the message has gone, and the upload still fails. Why?

Only `upload_max_filesize` went up. PHP discards a form larger than `post_max_size` whole, file included, so nothing is left to report. The Media Library's browser uploader goes back to the upload screen with no message, and a plugin upload says "The link you followed has expired." Raise both settings.

How high should I set the limit?

Above the largest file you expect to upload. PHP's manual adds two things that matter for large files. `memory_limit` should generally be larger than `post_max_size`: the page on the memory error (https://wpministry.co/errors/allowed-memory-size-exhausted/) shows how to raise it. And PHP allows 60 seconds by default to receive a request, upload included, so a large file on a slow connection can run out of time. That setting is `max_input_time`.

Does a multisite network have a limit of its own?

Yes. In the network admin, under Settings, then Network Settings, "Max upload file size" applies to every site on the network, and it is 1500 KB until someone changes it. A file over it gets a different message: "This file is too big. Files must be less than 1500 KB in size." Raise PHP's limits first, then that one.

## More on this subject

- WordPress errors and troubleshooting: https://wpministry.co/topics/wordpress-troubleshooting/
- Guide How to update the PHP version of a WordPress site: https://wpministry.co/blog/update-php-version-wordpress/
- Guide WordPress uptime monitoring: what a check sees and what it misses: https://wpministry.co/blog/wordpress-uptime-monitoring/
- Glossary term .htaccess: https://wpministry.co/glossary/htaccess/
- Guide Locked out of WordPress admin: find which lockout you have and get back in: https://wpministry.co/blog/locked-out-of-wordpress-admin/
- Glossary term Must-use plugin (mu-plugin): https://wpministry.co/glossary/must-use-plugin/
- Glossary term Permalink: https://wpministry.co/glossary/permalink/

## Would you rather we fixed it?

Quick Fix is $49. One issue, one site, up to about an hour. No fix, no fee. 30-day warranty.

More about this work: One-time WordPress fix (https://wpministry.co/services/one-time-fix/)

May we measure how this site is used?

A yes notes the pages of this visit and loads Google Analytics. A no keeps and loads nothing. See the cookies page (https://wpministry.co/legal/cookies/).

If you say yes, we note the pages you look at during this visit and load Google Analytics. If you say no, nothing is kept and nothing is loaded. The site works the same either way. The cookies page (https://wpministry.co/legal/cookies/) has the details.

## Structured data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "@id": "https://wpministry.co/#organization",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "logo": "https://wpministry.co/brand/logo.png",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "1309 Coffeen Ave STE 1200",
        "addressLocality": "Sheridan",
        "addressRegion": "WY",
        "postalCode": "82801",
        "addressCountry": "US"
      },
      "sameAs": [
        "https://www.linkedin.com/company/wp-ministry/",
        "https://x.com/wpministryco",
        "https://www.instagram.com/wpministryco/",
        "https://www.facebook.com/wpministryco",
        "https://www.tiktok.com/@wpministryco",
        "https://www.pinterest.com/wpministryco/",
        "https://www.youtube.com/channel/UCOZRuAukk5QSTRPG6BaHl3Q"
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://wpministry.co/#website",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      }
    },
    {
      "@type": "TechArticle",
      "@id": "https://wpministry.co/errors/upload-max-filesize/#article",
      "headline": "How to fix \"The uploaded file exceeds the upload_max_filesize directive in php.ini\" in WordPress",
      "description": "PHP refused a file larger than upload_max_filesize. Raise it and post_max_size together, in .htaccess, .user.ini or the host's PHP settings. Nothing is lost.",
      "url": "https://wpministry.co/errors/upload-max-filesize/",
      "mainEntityOfPage": "https://wpministry.co/errors/upload-max-filesize/",
      "inLanguage": "en-US",
      "image": "https://wpministry.co/og/errors/upload-max-filesize.png",
      "author": {
        "@id": "https://wpministry.co/#organization"
      },
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      },
      "datePublished": "2026-10-07T00:00:00.000Z",
      "dateModified": "2026-10-07T00:00:00.000Z"
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://wpministry.co/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Error fixes",
          "item": "https://wpministry.co/errors/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "How to fix \"The uploaded file exceeds the upload_max_filesize directive in php.ini\" in WordPress"
        }
      ]
    }
  ]
}
```