views:

94

answers:

3

Hi,

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.

+3  A: 

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

Gordon
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
Yes. But in CakePHP, in which file will I have to set it using ini_set?
lakum4stackof
@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
A: 

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.

Travis Leleu
A: 

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.

Leo