简体   繁体   中英

Request Entity Too Large PHP

In one of my CakePHP site, I got this error.

Request Entity Too Large

I don't know what is the problem. I think the data that I am posting through form is too large. I searched this in search engine and got that I will have to increase post_max_size . Be default I think it is set to 8M.

But don't know how to increase post_max_size in CakePHP and what to do for it?

Thanks.

post_max_size and upload_max_filesize are PHP.ini settings. You can set them either directly in PHP.ini or via ini_set . I don't know if this can be set with some Cake-internal tools as well.

However, the error could also be caused by a set limit of the RequestBodyLength in Apache (assuming you are running under Apache).

I tried all of these answers and the only thing that worked for me was to tune up the SSL Buffer Size. You can set this by...

<Directory /my/blah/blah>
...
  # Set this to something big big...
  SSLRenegBufferSize 10486000
...
</Directory>

...and then just restart Apache to take effect. (Found this at: http://forum.joomla.org/viewtopic.php?p=2085574 )

Another possible cause for the "413 request entity too large" error is mod-security. That was the cause for me.

Looking into the site's Apache error log said:

ModSecurity: Request body no files data length is larger than the configured limit (131072).. Deny with code (413)

On my Ubuntu 14.04 the config file is here but this really depends on the system:

/etc/modsecurity/modsecurity.conf

There is the default value for SecRequestBodyNoFilesLimit (and possibly also SecRequestBodyInMemoryLimit ).

Definitely not CakePHP problem but here are the two settings you need to set in order to upload files properly:

vim /etc/php5/php.ini (or wherever the .ini is located)

And set:

post_max_size="200M"
upload_max_filesize="200M"

Now the tricky part in case you are using HTTPS! you also need to configure one SSL.

vim /etc/apache2/sites-available/<whatever>-443.conf

And set the SSLRenegBufferSize

<Directory /appdata/www/<whatever>/web>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    allow from all
    SSLRenegBufferSize 201048600
</Directory>

I think you need to set that in the PHP config file, php.ini. If you have a VPS / root level access, just up the size on that. If you don't (shared hosting), you can modify the php ini parameters at runtime. Note that ini_set() won't work here, because the PHP settings are loaded too late (after the file has been uploaded, the PHP script begins execution).

You'll need to include the following in your htaccess file (on shared hosting):

php_value post_max_size 104857600

It's possible this won't work. Some googling around made it seem as though some shared hosts will lock down this setting, making it not over-rideable in htaccess (just in main server config). If that's the case, you'll need to move hosts.

Sometimes on shared hosting you can add your own php.ini file - just copy the relevant bits out of any default file (or google for one).

It's not an error I've seen before - it may as Gordon says, be Apache.

Don't be afraid to ask the hosting support team - I've always found them to be very helpful (I think they must get lonely), and often they will make config changes for you.

It certainly isn't a CakePHP problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM