php POST Content-Length 超出限制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6279897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
POST Content-Length exceeds the limit
提问by daza166
I get similar errors in my error_log in php when users are uploading their files
当用户上传他们的文件时,我在 php 中的 error_log 中遇到了类似的错误
PHP Warning: POST Content-Length of 11933650 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
PHP 警告:11933650 字节的 POST Content-Length 超出第 0 行未知中 8388608 字节的限制
In my php.ini (created custom ini file in public_html) would this solve this problem, how much would I have to set it to around 1GB? I am going to change my settings to this in php.ini, will it solve the problem?
在我的 php.ini(在 public_html 中创建自定义 ini 文件)中,这会解决这个问题,我需要将它设置为 1GB 左右吗?我要把我在php.ini中的设置改成这个,能解决问题吗?
upload_max_filesize = 1000M ;1GB
post_max_size = 1000M
What would I set the 'memory_limit' limit to.
我会将“memory_limit”限制设置为什么。
Also would this be correct in my script to check file uploaded size is <1GB
这在我的脚本中检查文件上传大小是否 <1GB 是否正确
if($_FILES["uploadedfile"]["size"]<1000000)
回答by ceejayoz
8388608 bytes is 8M, the default limit in PHP. Those changes to php.ini should indeed solve the problem (make sure your restart your Apache server after making them).
8388608 字节为 8M,PHP 中的默认限制。对 php.ini 的这些更改确实应该解决问题(确保在更改后重新启动 Apache 服务器)。
Memory limit shouldn't need to be changed here.
此处不需要更改内存限制。
回答by manson
I suggest that you should change to post_max_size
from 8M to 32M in the php.ini
file.
建议你post_max_size
把php.ini
文件里的8M改成32M 。
回答by Farid Blaster
you just setting at php.ini
您只需在 php.ini 中设置
then set :
然后设置:
upload_max_filesize = 1000M;
post_max_size = 1000M;
then restart your xampp.. Check the image
然后重新启动您的 xampp .. 检查图像
回答by Mel
Try pasting this to .htaccess and it should work.
尝试将其粘贴到 .htaccess 中,它应该可以工作。
php_value post_max_size 2000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M
回答by ArticIceJuice
post_max_sizeshould be slightly bigger than upload_max_filesize, because when uploading using HTTP POST method the text also includes headers with file size and name, etc.
post_max_size应该比upload_max_filesize稍大,因为当使用 HTTP POST 方法上传时,文本还包括带有文件大小和名称等的标题。
If you want to successfully uppload 1GiB files, you have to set:
如果你想成功上传 1GiB 文件,你必须设置:
upload_max_filesize = 1024M
post_max_size = 1025M
Note, the correct suffix for GB is G, i.e. upload_max_filesize = 1G.
注意,GB 的正确后缀是 G,即upload_max_filesize = 1G。
No need to set memory_limit.
无需设置memory_limit。
回答by Traveling Salesman
In Some cases, you need to increase the maximum execution time.
在某些情况下,您需要增加最大执行时间。
max_execution_time=30
I made it
我做到了
max_execution_time=600000
then I was happy.
然后我很高兴。
回答by Irfandi D. Vendy
There might be more than just one php.inifile. For example, when using WAMP there are 2 php.inifiles in following directories:
可能不止一个php.ini文件。例如,使用 WAMP 时,以下目录中有 2 个php.ini文件:
C:\wamp\bin\apache\apache2.4.9\bin
C:\wamp\bin\php\php5.5.12
C:\wamp\bin\apache\apache2.4.9\bin
C:\wamp\bin\php\php5.5.12
You need to edit the first one.
您需要编辑第一个。
回答by Marcio Muzzi
I disagree, but this solution to increase the file size in php.ini or .htaccess, will't work if the user send a file larger than allowed in the server application. I suggest validating this on the frontend. Example:
我不同意,但是如果用户发送的文件大于服务器应用程序中允许的文件,则此增加 php.ini 或 .htaccess 中文件大小的解决方案将不起作用。我建议在前端验证这一点。例子:
$(document).ready(function() {
$ ('#your_input_file_id').bind('change', function() {
var fileSize = this.files[0].size/1024/1024;
if (fileSize > 2) { // 2M
alert('Your custom message for max file size exceeded');
$('#your_input_file_id').val('');
}
});
});
回答by Satyanarayana
If you are using Php 5.6.X versions in windows using Wamp, then file location may be in,
如果您使用 Wamp 在 windows 中使用 Php 5.6.X 版本,则文件位置可能在,
C:\Windows\php.ini
C:\Windows\php.ini
Just try with
试试吧
post_max_size = 100M;
Try to do changes in Apache one. By that your Wamp/XAMP load .ini file
尝试在 Apache 中进行更改。通过你的 Wamp/XAMP 加载 .ini 文件