PHP error guide

post_max_size exceeded and POST is empty: meaning and fix

Error summary

Set post_max_size above the intended complete request size and detect oversized empty POST requests before treating fields as missing.

What it means

Set post_max_size above the intended complete request size and detect oversized empty POST requests before treating fields as missing.

What the error means

PHP rejected the entire request body before populating $_POST and $_FILES because Content-Length exceeded post_max_size.

Why PHP produces it

The total multipart body, including encoding overhead and all fields, is larger than the effective request limit.

PHP version notes

The behavior described for post_max_size exceeded and POST is empty applies to PHP 7.4–8.4 unless a narrower version is stated; exact wording can vary by SAPI and patch release.

Most common causes

  • post_max_size is smaller than upload_max_filesize.
  • Multiple files exceed the total body allowance.
  • A proxy permits a body larger than PHP accepts.

Minimal examples

BAD — reproduces the problem

ini
upload_max_filesize=16M
post_max_size=8M

FIXED — safer pattern

ini
upload_max_filesize=8M
post_max_size=10M

Step-by-step diagnosis

  1. Compare CONTENT_LENGTH with parsed shorthand bytes for post_max_size.
  2. Inspect the effective value in the web SAPI.
  3. Check upstream body limits separately.

Fixes

Align request limits and detect rejection

Choose measured application limits and keep post_max_size larger than upload_max_filesize.

ini
; site-specific php.ini
upload_max_filesize=8M
post_max_size=10M

Common mistakes when fixing it

  • Assuming empty $_POST means the browser sent no fields.
  • Raising limits without application validation.
  • Ignoring web-server and proxy limits.

How to prevent it

  • Publish client-side size guidance.
  • Validate size server-side after PHP accepts the request.
  • Keep limits consistent across proxy, server, and PHP.

Web server / environment notes

fpm, apache, shared-hosting. PHP rejects the body before application form validation.

Tags: fpm,apache,shared-hosting

Categories

Relevant ZendStudio.net tools