php configuration ai_generated true

Warning: POST Content-Length of 15728640 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

ID: php/file-upload-limit

Also available as: JSON · Markdown
93%Fix Rate
95%Confidence
80Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
83 active

Root Cause

File upload size limit errors occur when the uploaded file exceeds PHP's post_max_size or upload_max_filesize directive. Both directives must be set, and the web server (nginx/apache) may also impose its own limits.

generic

Workarounds

  1. 95% success Set upload_max_filesize, post_max_size, and web server limits together
    In php.ini: set upload_max_filesize = 64M, post_max_size = 70M (slightly larger). For Nginx, set client_max_body_size 70m in the server block. For Apache, set LimitRequestBody. Restart PHP-FPM and the web server.
  2. 88% success Implement chunked file uploads for large files
    Use a JavaScript uploader like Resumable.js or tus-js-client to split files into small chunks (e.g., 2MB each). The server receives each chunk separately and assembles them. This avoids hitting PHP limits entirely and supports resume on failure.

Dead Ends

Common approaches that don't work:

  1. Only increasing upload_max_filesize without also increasing post_max_size 78% fail

    post_max_size must be larger than upload_max_filesize. If post_max_size is smaller, the POST body is rejected before PHP even processes the file upload, and $_FILES will be empty with no clear error.

  2. Setting PHP directives via ini_set() in the upload handler script 85% fail

    post_max_size and upload_max_filesize cannot be set at runtime with ini_set() because they are PHP_INI_PERDIR directives. The POST body is already rejected before the script starts executing.

Error Chain

Leads to:
Preceded by:
Frequently confused with: