简体   繁体   English

如何避免:警告:POST内容长度47820076字节超过了第0行的Unknown中的8388608字节限制

[英]How to avoid: Warning: POST Content-Length of 47820076 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

I am posting an image file to the server and everything is fine. 我正在向服务器发布一个图像文件,一切都很好。 However, in cases when the user posts something bigger I get this warning. 但是,如果用户发布更大的内容,我会收到此警告。 What could I do to avoid this warning? 我该怎么做才能避免这种警告?

I don't want solutions that would hide the warning nor increase the post size. 我不想要隐藏警告的解决方案,也不希望增加邮政大小。 I want something that would block the request from uploading the file to the server entirely and catch that warning. 我想要一些阻止请求完全将文件上传到服务器并捕获该警告的内容。

This is what worked for me. 这对我有用。 It seems that when PHP sees a file that is too large, deletes all the POST data. 似乎当PHP看到文件太大时,删除所有POST数据。 So this code fragment worked for me: 所以这段代码片段对我有用:

if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_POST) < 1 ) {
    $_SESSION['error'] = 'File upload size exceeded';
    header('Location: index.php');
    return;
}

Of course your page should be designed not to submit empty POST pages with no input parameters. 当然,您的页面应设计为不提交没有输入参数的空POST页面。

One thing what you can do is give a maximum size on the HTML form. 您可以做的一件事是在HTML表单上给出最大大小。

<input type="hidden" name="MAX_FILE_SIZE" value="4194304" /> 

It's not bulletproof, but it has some impact. 它不是防弹的,但它有一些影响。 Why this is not so good is explained in this comment - it is only checked by PHP, so uploading will start and continue up until this limit is reached. 为什么这不是那么好在本评论中解释 - 它仅由PHP检查,因此上传将开始并继续,直到达到此限制。

My recommendation is that you could use that together with a javascript solution, as described here . 我的建议是,你可以一起使用了JavaScript的解决方案,如所描述这里 It only works if javascript is enabled, of course. 它只适用于启用javascript的情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:90612004 字节的 POST Content-Length 超出了第 0 行未知中 8388608 字节的限制 - Warning: POST Content-Length of 90612004 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 PHP 警告:8978294 字节的 POST 内容长度超出第 0 行未知中 8388608 字节的限制 - PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 警告:POST Content-Length的25447804字节超出了第0行上Unknown中的8388608字节的限制 - Warning: POST Content-Length of 25447804 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 PHP 警告:8412174 字节的 POST Content-Length 超出了 Unknow 中 8388608 字节的限制 - PHP Warning: POST Content-Length of 8412174 bytes exceeds the limit of 8388608 bytes in Unknow 警告:11394639字节的POST内容长度超过了8388608字节的限制 - Warning: POST Content-Length of 11394639 bytes exceeds the limit of 8388608 bytes PHP 警告:未知:68 字节的 POST 内容长度超过第 0 行未知中 10 字节的限制, - PHP Warning: Unknown: POST Content-Length of 68 bytes exceeds the limit of 10 bytes in Unknown on line 0, PHP警告:53160843字节的POST内容长度超过了行0上“未知”中的33554432字节的限制 - PHP Warning: POST Content-Length of 53160843 bytes exceeds the limit of 33554432 bytes in Unknown on line 0 PHP警告:POST内容 - n个字节的长度超过了第0行的Unknown中的3145728个字节的限制 - PHP Warning: POST Content-Length of n bytes exceeds the limit of 3145728 bytes in Unknown on line 0 无法解决:PHP警告:POST Content-Length的13110857字节超出了第0行上Unknown中的10485760字节的限制 - Cannot solve: PHP Warning: POST Content-Length of 13110857 bytes exceeds the limit of 10485760 bytes in Unknown on line 0 PHP 警告:113 字节的 POST 内容长度超出未知中 -1988100096 字节的限制 - PHP Warning: POST Content-Length of 113 bytes exceeds the limit of -1988100096 bytes in Unknown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM