71

There is a lot of data being submitted no file uploads and the $_SERVER['CONTENT_LENGTH'] is being exceeded. Can this be increased?

kero
  • 10,647
  • 5
  • 41
  • 51
Daniel
  • 749
  • 1
  • 5
  • 4
  • I assume that you are using apache, which is actually limiting the post size. – Ikke May 26 '11 at 08:03
  • 2
    possible duplicate of [Upload max size in PHP?](http://stackoverflow.com/questions/3263480/upload-max-size-in-php) – Ikke May 26 '11 at 08:04
  • Read [this article on drupal](https://www.drupal.org/node/97193) on how the post_max_size and upload_max_filesize relate – Raphioly-San Jun 08 '15 at 09:53

11 Answers11

144

There are 2 different places you can set it:

php.ini

post_max_size=20M
upload_max_filesize=20M

.htaccess / httpd.conf / virtualhost include

php_value post_max_size 20M
php_value upload_max_filesize 20M

Which one to use depends on what you have access to.

.htaccess will not require a server restart, but php.ini and the other apache conf files will.

John Green
  • 13,241
  • 3
  • 29
  • 51
79

I had a situation when variables went missing from POST and all of the above answers didn't help. It turned out that

max_input_vars=1000

was set by default and POST in question had more than that. This may be a problem.

RandomWhiteTrash
  • 3,974
  • 5
  • 29
  • 42
  • Great thank you - this was the only thing that did the trick, for me. – Stefan Jul 04 '16 at 15:33
  • 1
    it's the right answer. be aware that you should not set this value from php but it must be set from php.ini or htaccess. for htaccess use like this: php_value max_input_vars 4000 – webelizer Aug 14 '16 at 11:01
  • Thanks this max_input_vars=3000, works for me, not post_max_size – ederrafo Nov 19 '21 at 04:32
25
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
Muhammad Zeeshan
  • 8,722
  • 10
  • 45
  • 55
8

We can Increasing the maximum limit using .htaccess file.

php_value session.gc_maxlifetime 10800
php_value max_input_time         10800
php_value max_execution_time     10800
php_value upload_max_filesize    110M
php_value post_max_size          120M

If sometimes other way are not working, this way is working perfect.

Neel Thakkar
  • 406
  • 6
  • 14
8

You can do this with .htaccess:

php_value upload_max_filesize 20M
php_value post_max_size 20M
RJD22
  • 10,230
  • 3
  • 28
  • 35
6

I had been facing similar problem in downloading big files this works fine for me now:

safe_mode = off
max_input_time = 9000
memory_limit = 1073741824
post_max_size = 1073741824
file_uploads = On
upload_max_filesize = 1073741824
max_file_uploads = 100
allow_url_fopen = On

Hope this helps.

ahmed
  • 498
  • 6
  • 13
6

You can increase that in php.ini

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Ivan Lazarevic
  • 371
  • 2
  • 7
5

You can specify both max post size and max file size limit in php.ini

post_max_size = 64M
upload_max_filesize = 64M
NathanD
  • 380
  • 4
  • 11
1

Try

LimitRequestBody 1024000000
Andy
  • 49,085
  • 60
  • 166
  • 233
pavel
  • 11
  • 1
0

php.ini
Change setting max_input_vars from default 1000 to 10000 for enought json post data.
It worked for me.

max_input_vars=10000
-1

Only add the below 3 lines in .htaccess file, which is in your root folder of the project.

php_value memory_limit 500M
php_value post_max_size 500M
php_value upload_max_filesize 500M 

It will completely assist you in resolving your problem.

Ketan Chaudhari
  • 329
  • 3
  • 7