$_POST请求期间数据被截断

4

我遇到了一个问题,无法确定以下 $_POST 请求的问题所在。问题是我通过 AJAX 提交了一个包含 855 条记录的数组,但我的 AJAX 控制器只接收到了 833 条记录。总是接收到相同的记录,并且总是在同一点截断:

JQuery:

var f = {};
f.chargeID = chargeID;
f.method = 'saveIndividualApplications';
f.individualAmounts = individualAmts;

processing.show();

console.log(f); //all records present
console.log(Object.keys(f.individualAmounts).length); //855

return $.ajax({
    type: 'post',
    cache: false,
    url: appControllerPath,
    data: f
});

PHP控制器:

$displayMaxSize = ini_get('post_max_size'); //125912
file_put_contents('post', $_SERVER['CONTENT_LENGTH'] . "\r\n"); //240M (increased this to 240 just to check)
file_put_contents('post', $displayMaxSize . "\r\n", FILE_APPEND);
file_put_contents('post', print_r($_SERVER, true), FILE_APPEND);
file_put_contents('post', count($_POST['individualAmounts']) . "\r\n", FILE_APPEND); //833
file_put_contents('post', print_r($_POST['individualAmounts'], true), FILE_APPEND); // data cuts off midway through 833rd record (although the array seems to close fine)

你是否启用了某种超时功能? - Script47
@Script47 这个请求不会有太大的压力。在这两个点之间没有任何处理 - 只是简单的发送和接收。它非常快速地完成(几秒钟)。 - Eamonn
文章最大大小的单位类型是什么? - schellingerht
@HenriSchellingerhout 我没有设置标志,所以是字节(对吗?) - Eamonn
1个回答

13

它可以通过max_input_vars配置选项进行限制,默认情况下限制为1000。此功能引入于5.3.9版本,请查看PHP运行时配置

或者如果您使用的是Suhosin,则可能会受到它的限制。

[suhosin]
suhosin.request.max_vars = 1000
suhosin.post.max_vars = 1000

这是正确的 - 非常感谢,我永远不会找到它。将其设置为2500,所以将其提高到3500,所有记录都通过了。 - Eamonn
值得注意的是,max_input_vars 无法通过 ini_set() 进行修改。 - Leigh Bicknell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接