PHP file upload exceeds upload\_max\_filesize - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

PHP file upload exceeds upload\_max\_filesize
=============================================

### [\#PHP](https://rocketeersapp.com/knowledge/php)

When a file upload silently fails or is empty, PHP itself is usually rejecting it because it is larger than upload\_max\_filesize or post\_max\_size. This is the PHP-side companion to the nginx 413 error.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [Don't forget the layers in front of PHP](#content-dont-forget-the-layers-in-front-of-php)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

Unlike most errors, this one is quiet. The upload just doesn't arrive, `$_FILES` is empty, or you see `UPLOAD_ERR_INI_SIZE` in the file's `error` key. PHP discarded the file before your code ever ran.

This is distinct from, but often confused with, the [413 Request Entity Too Large](/413-request-entity-too-large) error. That one is nginx rejecting the request before it reaches PHP. If you've already raised nginx's `client_max_body_size` and uploads still fail, PHP's own limits are the next place to look.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

Two PHP settings cap upload size, and the *lower* of the two wins:

- `upload_max_filesize`, the maximum size of a single uploaded file.
- `post_max_size`, the maximum size of the entire POST body (which must be larger than `upload_max_filesize`, with room for other fields).

If either is smaller than the file, PHP drops it.

[\#](#content-solution "Permalink")Solution
-------------------------------------------

Raise both values in your `php.ini`. `post_max_size` should be a bit larger than `upload_max_filesize`:

 ```
upload_max_filesize = 100M
post_max_size = 110M

```

While you're there, check these related limits don't cut a large upload short:

 ```
max_file_uploads = 20
max_execution_time = 120
memory_limit = 256M

```

Reload PHP-FPM so the changes take effect:

 ```
systemctl reload php8.3-fpm

```

### [\#](#content-dont-forget-the-layers-in-front-of-php "Permalink")Don't forget the layers in front of PHP

A large upload has to pass through every layer to succeed. All of these must be big enough:

- **nginx**, via `client_max_body_size`, see [413 Request Entity Too Large](/413-request-entity-too-large).
- **PHP**, via `upload_max_filesize` and `post_max_size` above.
- **Your application's own validation**, for example a Laravel `max:` rule on the file.

Verify the active PHP values with:

 ```
php -i | grep -E 'upload_max_filesize|post_max_size'

```

Note that the CLI and the FPM SAPI can use different `php.ini` files, so check the FPM one (`/etc/php/8.3/fpm/php.ini`) for web uploads.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#PHP](https://rocketeersapp.com/knowledge/php)

- [How to run PHP files](https://rocketeersapp.com/knowledge/run-php-files)
- [PHP Warning: Undefined array key](https://rocketeersapp.com/knowledge/undefined-array-key-php)
- [PHP Fatal error: Allowed memory size exhausted](https://rocketeersapp.com/knowledge/php-allowed-memory-size-exhausted)
- [PHP: Call to a member function on null](https://rocketeersapp.com/knowledge/call-to-a-member-function-on-null)
- [PHP Fatal error: Class "X" not found](https://rocketeersapp.com/knowledge/php-class-not-found)
- [Composer out of memory (allowed memory size exhausted)](https://rocketeersapp.com/knowledge/composer-out-of-memory-allowed-memory-size-exhausted)

 [View all 11 articles →](https://rocketeersapp.com/knowledge/php)
