# Upload error: File too large (LIMIT_FILE_SIZE / file exceeds maximum upload size)

**Code:** `LIMIT_FILE_SIZE` · **Category:** API · **Seen on:** REST API

The uploaded file is larger than the limit set by the API, framework or server.

## Meaning

Limits exist at several layers: the app (Multer LIMIT_FILE_SIZE “File too large”, Laravel “may not be greater than 2048 kilobytes”), the language runtime (PHP upload_max_filesize / post_max_size), the web server (Nginx client_max_body_size → 413) and the provider (S3 single PUT 5 GB, many APIs 10–100 MB).

The smallest limit wins, so raising one layer isn’t enough if another is lower.

## Common causes

- File genuinely above the documented limit
- Framework limit lower than the server limit (or vice versa)
- Multipart overhead or base64 encoding (+33%) pushes it over
- Proxy/CDN limit in front of the app

## Quick fix

1. Compress or resize before uploading
2. Use the provider’s multipart/chunked or resumable upload for large files
3. Raise the limit at every layer you control (app, PHP, web server, proxy)

## Detailed fix by platform

### Node.js

1. `const upload = multer({ limits: { fileSize: 20 * 1024 * 1024 } });   // 20 MB`

### PHP

1. 

```php
; php.ini
upload_max_filesize = 20M
post_max_size = 25M
```


### Nginx

1. `client_max_body_size 25m;`

## How to diagnose

1. **Size** — Actual file and request size
2. **Layers** — App, runtime, web server, proxy limits
3. **Encoding** — Is the file base64-encoded in JSON?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/api/file-size-limit-exceeded)
