1

When submitting a form with file attachment that exceeds the POST Content-Length limit I get the following warning

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

My issue is that for some reason PHP acts as if $_POST['form_input_field'] does not exist and I get this error

Undefined index: form_input_field ...

The inputs exist and contain values, and if the file does not exceed the limit, PHP gets it just fine.

I solve the issue by adding isset isset($_POST['form_input_field']). but is there an explanation as to why PHP can't get $_POST['form_input_field']?

EDIT:

I don't have a problem with the limit and don't want to increase it.

EDIT I have no intention of increasing the upload limit. I simply want to know why PHP thinks $_POST['form_input_field'] does not exist after the warning.

  • _is there an explanation as to why PHP can't get input_ Its in the warning message...! – Thamilhan May 09 '16 at 05:11
  • Possible duplicate of [What is the size limit of a post request?](http://stackoverflow.com/questions/2364840/what-is-the-size-limit-of-a-post-request) – Geoff Atkins May 09 '16 at 05:21
  • I checked, my question is different. –  May 09 '16 at 05:26
  • 1
    because your field name and variable you are checking are different, just check this : `$_POST['form_input_1']`, you are checking isset for this, and your variable is `$_POST['form_input_field']`. @Shabbb – Nehal May 09 '16 at 05:32
  • there the same in my code, just a mistake on the post. –  May 09 '16 at 05:38

2 Answers2

3

You should increase your post limit

using php.ini

post_max_size=20M
upload_max_filesize=20M

using .htaccess / httpd.conf / virtualhost include

php_value post_max_size 20M
php_value upload_max_filesize 20M

Note : 20M stand for an example change it according to your requirement

Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44
2

To answer the actual question "Is there an explanation as to why PHP can't get input?" under the circumstance of "I don't have a problem with the limit and don't want to increase it." :

It's a weird behavior of PHP, which removes all other POST data in case you exceed that limit. It is possibly like that because if one part of the POST violates the rules, the POST is rendered invalid all-together (which makes sense)

If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty.

You can read about it here http://php.net/manual/en/ini.core.php#ini.post-max-size

nico gawenda
  • 3,648
  • 3
  • 25
  • 38