我无法弄清楚以下 $_POST 请求的问题所在。问题是我通过 AJAX $_POSTing 一个包含 855 条记录的数组,但我的 AJAX Controller 只接收 833。它总是接收到相同的记录,并且它总是在同一点切断:
查询:
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 Controller :
$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)
最佳答案
可以通过 max_input_vars
配置选项进行限制,默认限制为 1000。在 5.3.9 中引入,检查 PHP runtime config
或者,如果您使用的是 Suhosin,则可能会受到它的限制
[suhosin]
suhosin.request.max_vars = 1000
suhosin.post.max_vars = 1000
关于php - $_POST 请求期间数据中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31878374/