Ffile2fix
Sign in Get started

How to fix "POST Content-Length exceeds the limit" in PHP

PHP Warning:  PHP Request Startup: POST Content-Length of 73400320 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

The whole POST request was bigger than post_max_size (8M by default), so PHP discarded it before your script ran. $_POST and $_FILES arrive empty, which often looks like a form that "does nothing" or a CSRF/nonce failure. Raise post_max_size above your largest expected request.

Also appears as: Warning: POST Content-Length of 10485760 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 · PHP Warning: Unknown: POST Content-Length of 52428800 bytes exceeds the limit of 41943040 bytes · Empty $_POST and $_FILES after submitting a large form

Common causes

  • post_max_size is still at the 8M default
  • upload_max_filesize was raised but post_max_size was not
  • Several files uploaded in one form add up to more than the limit
  • Large base64-encoded data or JSON sent in a form field
  • Edits made to a php.ini that the web server does not load

How to fix it

  1. Compare the numbers. The first number is the request size, the second is post_max_size in bytes (8388608 = 8M). You need post_max_size above the first number.
  2. Raise post_max_size. In the active php.ini or .user.ini set post_max_size = 72M, and keep upload_max_filesize a bit lower, for example 64M.
  3. Restart PHP and verify. Restart PHP-FPM or Apache and confirm the new value in phpinfo(). Check the Loaded Configuration File line to be sure you edited the right file.
  4. Check server body limits. Set Nginx client_max_body_size or Apache LimitRequestBody to at least the same size, otherwise the server returns 413 instead.
  5. Detect the problem in code. If $_POST is empty but $_SERVER['CONTENT_LENGTH'] is greater than zero, show a clear message that the upload was too large instead of failing silently.

Detect an oversized POST in your form handler

if ($_SERVER['REQUEST_METHOD'] === 'POST'
    && empty($_POST) && empty($_FILES)
    && (int) ($_SERVER['CONTENT_LENGTH'] ?? 0) > 0) {
    exit('The upload is larger than the server allows (post_max_size).');
}

How to stop it happening again

  • Set post_max_size and upload_max_filesize together
  • Show the maximum upload size on your upload forms
  • Validate file size in the browser before submitting
  • Use chunked uploads for very large files

Frequently asked questions

Why does the message say "Unknown on line 0"?

PHP rejected the request during startup, before any script file was running. That is why there is no file or line number.

Why did my login or nonce check fail?

PHP dropped all POST fields, including the token, so the form looks invalid. Fix the size limit and the check passes.

What is a safe size to set?

Set it a little above the largest file your users really need to upload. Very large limits let a few requests use a lot of disk and bandwidth.