21

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.

6 Answers 6

29

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).

5
  • 5
    Additionally, everywhere that Apache bails with HTTP_REQUEST_ENTITY_TOO_LARGE, there's a log statement, so there should be a description of what exactly offended Apache about the size of the request in the error log.
    – Tim Stone
    Commented Sep 15, 2010 at 20:50
  • Yes. But in CakePHP, in which file will I have to set it using ini_set? Commented Sep 16, 2010 at 8:16
  • @lakum In the bootstrap file. But like Travis points out below, some ini values cannot be set at runtime. I havent checked if this applies to post_max_size and upload_max_filesize.
    – Gordon
    Commented Sep 16, 2010 at 8:22
  • 3
    @TimStone Where can i see those logs? Have a godaddy apache server Commented Feb 14, 2014 at 7:47
  • @TimStone what the form of the error message should be? I cannot find related error message in my error.log
    – petertc
    Commented Apr 11, 2016 at 6:49
13

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)

1
  • Just changed over to requiring SSL. This solved it.
    – zachswain
    Commented Jan 29, 2016 at 18:34
7

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).

3

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>
1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.