WordPress & PHP guides

Why WordPress Still Rejects Your File After You Raise the Upload Limit

Author: Lucky Oleg | Published

When WordPress says “The uploaded file exceeds the upload_max_filesize directive in php.ini,” check the PHP settings the site actually uses. Go to Tools → Site Health → Info → Media Handling. The file must fit upload_max_filesize, and the whole form submission must fit post_max_size. If both look high enough, check the response to the failed upload before changing another setting.

On our test site, the Media screen showed 2 MB and our file was exactly 2 MiB (2,097,152 bytes). The upload failed. The form added 355 bytes, which pushed the request past PHP’s limit. WordPress told us the link had expired.

How one file produced two different WordPress upload errors

We signed in to a disposable WordPress Playground site and submitted the same plain-text file to the Media Library’s upload endpoint under three configurations. We used WordPress 7.1.5 and PHP 8.3.37, starting with an empty library each time. We sent the form directly so we could observe what the server did even when the browser uploader might have stopped the file first.

PHP file limitPHP POST limitMaximum shown in MediaWhat happened
1M4M1 MBWordPress returned the upload_max_filesize error. The library stayed empty.
3M2M2 MBThe upload returned HTTP 403 and “The link you followed has expired.” The library stayed empty.
3M4M3 MBWordPress created an attachment. We downloaded it and verified that its size and SHA-256 checksum matched the original.

The first rejection arrived in a response with HTTP 200. The response body reported failure, and PHP had assigned the file upload error code 1. If you only check for a red network request in the browser, you can miss this error.

In the second test, the file fit under 3M. The request exceeded 2M. A separate diagnostic request with the same body showed that PHP had discarded both the form fields and the file. That included the security token WordPress expected. The expired-link message was how this upload endpoint handled the missing token. Other forms may describe the same problem differently. PHP documents what happens when a POST exceeds the limit.

A file of 2,097,152 bytes plus 355 bytes of form data made a 2,097,507-byte request, 355 bytes over the 2 MiB POST limit.
The exact body we sent. The extra bytes held the form fields, file details and multipart boundaries. Their size changes with the form.

Read the limits for the site that failed

Open Media → Add Media File and note the maximum under the uploader. Then go to Tools → Site Health → Info → Media Handling on that same site. In the English Site Health screen, check that File uploads says Enabled. The next three rows explain which limit applies.

Site Health labelWhat it tells you
Max size of an uploaded fileThe PHP limit on one file, upload_max_filesize.
Max size of post data allowedThe PHP limit on the whole form submission, post_max_size.
Max effective file sizeThe smaller of those two configured values. In our 3M / 2M configuration, the full 2 MiB allowance was already used by the file alone.

For ordinary positive limits, WordPress takes the smaller PHP value and passes it through the upload_size_limit filter. A plugin or a network setting can therefore change what the uploader displays. The calculation cannot tell how large a request your hosting proxy will accept, or exactly how many bytes a particular form will add.

If the hosting panel says 64M and Site Health still says 8M for the same directive, resolve that discrepancy first. Check the domain, whether you changed staging or production, and which PHP version serves that domain. A terminal command such as php --ini describes the command-line PHP configuration. A host can run the website with a different configuration.

Increase the PHP limit without guessing at the others

Suppose an editor needs to upload a single PDF up to 32 MiB. On a host that supports these limits, this example leaves room for the rest of the form. Enter the values in the PHP settings for that domain.

upload_max_filesize = 32M
post_max_size = 40M

Here the 8 MiB difference leaves room for the form. A form that puts two 30 MiB files in one request would still exceed 40M. Check whether your uploader sends the files separately or together before choosing the values.

Use the PHP settings in the hosting panel if available. Record the previous values, set the finite limits the upload needs, and reload the admin screens to check what PHP now reports. On hosts that support it, a per-directory .user.ini file is another option for CGI/FastCGI PHP. The default refresh interval for that file is five minutes. Your host can change or disable that mechanism.

If your host uses Apache with mod_php, ask whether PHP settings in .htaccess are allowed before editing that file. Check PHP’s configuration modes if you are unsure which settings a script can change. A change to WP_MEMORY_LIMIT addresses a different problem. If PHP accepted the image and the error log records memory exhaustion while generating thumbnails, follow the WordPress memory limit guide. If you just need a smaller JPEG or PNG for a page, try a copy in the image compressor and compare the result before replacing the original.

When Site Health looks right, follow the failed request

The uploader refuses the file immediately. Open your browser’s developer tools, select Network, and try once more. If no upload request appears, check the limit and allowed file types shown on that particular form. If the core Media uploader accepts the same file, investigate the form or plugin that refused it.

A request returns HTTP 413. Give the host the upload path, the time including time zone, the file size and the HTTP status. Ask which component produced the response. For example, nginx can return 413 when the body exceeds client_max_body_size. Apache’s LimitRequestBody can also restrict a request, and a proxy in front of either server may have its own limit. Site Health cannot inspect those settings. Our Playground test covered PHP and WordPress only.

One site in a WordPress Multisite network shows a smaller maximum. Ask the network administrator to open Network Admin → Settings → Upload Settings. There are separate controls for maximum file size in KB, allowed file types, and site storage. With space checking enabled, WordPress also includes remaining space in its calculation. A site with 6 MiB left cannot take an 8 MiB file even if the network permits 32 MiB per file. Check the network upload settings before increasing PHP across the network.

Even a small file fails. Retry with a small file of a type the same uploader allows, using a freshly loaded form. A message about a missing temporary directory, a write failure or a forbidden type points to a different check. Preserve the exact wording. Increasing the size limit will leave those problems in place. If the upload triggers a WordPress critical error, check the failing component before raising limits.

What counts as a successful fix?

Repeat the original task using the same file, account and upload screen. For a Media upload, look for the new attachment, then open its file URL. For a form, confirm the submission contains the expected file. In our test, Media showed 2 MB and a 2 MiB file still failed. It took a 2,097,507-byte request to deliver the 2,097,152-byte file.

If a host and a site maintainer share responsibility, one compact message gives both of them something to check. Include the affected upload screen, exact file size, both Site Health values, and the status and wording from the failed attempt. Omit the file itself if it contains private information. If you need help distinguishing a hosting limit from a form or media-processing error, those details are also a useful starting point for WordPress maintenance support.

Useful info? Spread the Aloha:

Lucky Oleg

Lucky Oleg is the founder of Web Aloha, a web design & SEO agency helping businesses ride the digital wave. With years of experience in WordPress, technical SEO, and web performance, he writes about what actually works in the real world.