请求实体太大 PHP

发布于 2024-09-19 16:05:29 字数 220 浏览 5 评论 0原文

在我的 CakePHP 网站之一中,我收到此错误。

请求实体太大

我不知道是什么问题。我认为我通过表单发布的数据太大。我在搜索引擎中搜索了这个,发现我必须增加 post_max_size。默认情况下我认为它设置为8M。

但不知道如何增加 CakePHP 中的 post_max_size 以及该怎么做?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

梦忆晨望 2024-09-26 16:05:30

post_max_sizeupload_max_filesize 是 PHP.ini 设置。您可以直接在 PHP.ini 中设置它们,也可以通过 ini_set< /代码>。我不知道是否也可以使用一些 Cake 内部工具来设置。

但是,该错误也可能是由 Apache 中的 RequestBodyLength 设置限制引起的(假设您在 Apache 下运行)。

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

み青杉依旧 2024-09-26 16:05:30

我尝试了所有这些答案,唯一对我有用的是调整 SSL 缓冲区大小。你可以这样设置...

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

...然后重新启动Apache即可生效。 (发现此:http://forum.joomla.org/viewtopic.php?p=2085574

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)

故事未完 2024-09-26 16:05:30

“413 请求实体太大”错误的另一个可能原因是 mod-security。这就是我的原因。

查看该网站的 Apache 错误日志后发现:

ModSecurity:请求正文没有文件数据长度大于配置的限制 (131072).. 使用代码拒绝 (413)

在我的 Ubuntu 14.04 上,配置文件位于此处,但这实际上取决于系统:

/etc/modsecurity/modsecurity.conf

SecRequestBodyNoFilesLimit 的默认值(也可能有 SecRequestBodyInMemoryLimit)。

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

你又不是我 2024-09-26 16:05:30

绝对不是 CakePHP 的问题,但为了正确上传文件,您需要设置以下两个设置:

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

并设置:

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

现在是棘手的部分,以防您使用 HTTPS!您还需要配置一个 SSL。

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

并设置 SSLRenegBufferSize

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

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>
鼻尖触碰 2024-09-26 16:05:30

我认为您需要在 PHP 配置文件 php.ini 中进行设置。如果您有 VPS/根级别访问权限,只需增加其大小即可。如果不这样做(共享主机),您可以在运行时修改 php ini 参数。请注意,ini_set() 在这里不起作用,因为 PHP 设置加载得太晚(文件上传后,PHP 脚本开始执行)。

您需要在 htaccess 文件(在共享主机上)中包含以下内容:

php_value post_max_size 104857600

这可能不起作用。一些谷歌搜索看起来好像一些共享主机会锁定此设置,使其在 htaccess 中不可覆盖(仅在主服务器配置中)。如果是这种情况,您需要移动主机。

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.

夜雨飘雪 2024-09-26 16:05:30

有时,在共享主机上,您可以添加自己的 php.ini 文件 - 只需从任何默认文件(或 google 之一)中复制相关位即可。

这不是我以前见过的错误 - 正如戈登所说,它可能是 Apache 的错误。

不要害怕询问托管支持团队 - 我一直发现他们非常有帮助(我认为他们一定会感到孤独),并且他们通常会为您进行配置更改。

这当然不是 CakePHP 问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文