PHP /阿帕奇/ AJAX - POST限制? [英] PHP/Apache/AJAX - POST limit?
问题描述
我想发送POST数据为200万字符的大(非二进制字符串)通过AJAX(jQuery的),它总是出现在PHP端为空白。这是我的code:
I'm trying to send POST data that is 2 million characters big (non-binary string) via ajax (jQuery) and it always comes up as blank on the PHP side. Here is my code:
var string = "<data string that is 2M chars long>";
$.ajax({
cache: false,
type: 'POST',
url: 'data.php',
data: {'data_string': string}
});
在PHP端,我得到了以下错误消息(尝试从 $数据时_ POST ['data_string']
):
On the PHP side, I get the following error message (when trying to retrieve data from $_POST['data_string']
):
Notice: Undefined index: data_string in data.php on line ...
我已经检查了的post_max_size
在php.ini,并把它设置为256M应该是绰绰有余?我很为难,不知道我做错了...
I've checked the post_max_size
in php.ini, and it's set at 256M which should be more than enough? I'm stumped and not sure what I'm doing wrong...
编辑:如果我让字符串
少量的数据(如 VAR字符串='测试'
),那么 $ _ POST [data_string]
返回测试
,符合市场预期。所以,我不知道是否有某种形式的数据限制我达成的Apache2,PHP或浏览器本身?我使用谷歌浏览器17.0.963.79
If I make "string"
a small amount of data (e.g. var string = 'test'
) then $_POST["data_string"]
returns test
, as expected. So I'm wondering if there's some sort of data limit I'm reaching in Apache2, PHP or the browser itself? I'm using Google Chrome 17.0.963.79
EDIT2: memory_limit的= 256M
在php.ini
memory_limit = 256M
in php.ini
EDIT3: max_input_time设置= -1
在php.ini
max_input_time = -1
in php.ini
EDIT4:后续代码var_dump($ _ POST)返回阵列(0)
var_dump($_POST) returns Array(0)
EDIT5:运行PHP5的Debian的挤压最新的稳定版本:PHP 5.3.3-7 + squeeze8用了Suhosin-补丁(CLI)(内置:2012年2月10号14点12分26秒)
running the latest stable version of PHP5 on debian squeeze: PHP 5.3.3-7+squeeze8 with Suhosin-Patch (cli) (built: Feb 10 2012 14:12:26)
推荐答案
你必须检查你和服务器之间的所有项目的限制参数。挺难的代理服务器(如果有),但至少你可以检查:
You'll have to check the limits parameters on all items between you and the server. Quite hard for proxy servers if any, but at least you can check:
阿帕奇:
- LimitRequestBody ,周围的2Gb在默认情况下,为64位,也许更大,检查错误日志了解详细信息。
- LimitRequestBody, around 2Gb by default, maybe greater for 64bits, check error logs for details.
PHP:
- 的post_max_size 这直接关系到POST大小
- 的upload_max_filesize 这可能是不相关的,不知道
- max_input_time设置,若后期时间过长
- <一个href="http://www.php.net/manual/en/info.configuration.php#ini.max-input-nesting-level">max-input-nesting-level如果您的数据是一个有很多的子层的数组
- <一个href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time">max_execution_time,但很肯定它不是
- memory_limit的,因为你可能会达到大小exceding子进程允许内存
- max_input_vars 的,如果你的数据数组有很多元素
- post_max_size which is directly related to the POST size
- upload_max_filesize which may be unrelated, not sure
- max_input_time, if the POSt takes too long
- max-input-nesting-level if your data is an array with a lot of sublevels
- max_execution_time, but quite sure it's not that
- memory_limit, as you may reach a size exceding the subprocess allowed memory
- max_input_vars, if your data array has many elements
如果你已经达到了编制的限制阿帕奇你唯一的解决办法就是避免这样的数据很大一部分直接的帖子,你必须打破成碎片。
If you have reached the compiled in limit for Apache your only solution is to avoid direct POSt of such a big chunk of data, you'll have to break it into pieces.
这篇关于PHP /阿帕奇/ AJAX - POST限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!