问题描述
我有一个多维数组,它由426更小的数组,其中还包括了4个属性。下面是426的阵列的一个例子...
阵列(//主阵列
0 => 426阵列阵列(// 1
'名'=> 丹尼,
电子邮件=> your@email.com,
picture_url'=> http://www.website.com,
'分数'=> 89
),
)
我张贴此数组与jQuery的Ajax功能的PHP文件,该文件将其添加到数据库...我的问题是,数组似乎被砍断,当它发布到PHP文件。只有大约一半的阵列实际到达的php文件...
这使我相信,张贴在阿贾克斯时,有可能是文件大小限制。然而,我的数组的大小似乎是比较小的。
我跑我的WAMP的应用程序。
任何人都可以提供一些线索什么可能发生?
更新:
我张贴我的数组像这样:
$。阿贾克斯({
键入:POST,
网址:invite_friends.php
数据: {
theID:me.id,
朋友:multidimensional_array //这是数组< ---
},
成功:功能(数据,textStatus,jqXHR){
返回的console.log(数据);
},
错误:函数(jqXHR,textStatus,errorThrown){
返回警报(错误:哎呀,出现了一个问题);
}
});
和我找回我的数组(在invite_friends.php)像这样..
如果($ _ POST ['朋友']){
$朋友= $ _ POST ['朋友'];
} 其他 {
$朋友= FALSE;
}
您需要打开你的的php.ini
文件和设置(或创建)该行:
max_input_vars = 1000000
max_input_vars
有1000的默认值,这将切断阵列在1000总要素。只需将其更改为一个真正的高数(在我的情况,我需要将其设置为一百万)。
从PHP手册:
请注意:作为手册上说,这个缺省限制是落实到位,以prevent拒绝服务攻击。
希望这有助于即使这是一个老问题。
I have a multidimensional array, which consists of 426 smaller arrays, which also comprise of 4 attributes.. Below is an example of one of 426 arrays...
array( //Main array
0 => array( //1 of 426 arrays
'name' => 'Danny',
'email' => 'your@email.com',
'picture_url' => 'http://www.website.com',
'score' => 89
),
)
I'm posting this array with jquery's ajax functions to a php file, which adds them to a database... My problem is that the array seems to be chopped off when it's posted to the php file. Only about half the array actually reaches the php file...
This has led me to believe that there may be a file size limit when posting over ajax. However, the size of my array seems to be relatively small..
I'm running my application on WAMP..
Can anyone shed some light what's possibly happening?
UPDATE:
I'm posting my array like so:
$.ajax({
type: "POST",
url: "invite_friends.php",
data: {
theID: me.id,
friends: multidimensional_array //This is the array <---
},
success: function(data, textStatus, jqXHR) {
return console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
return alert("Error: Oops, there has been a problem");
}
});
And I retrieve my array (in invite_friends.php) like so..
if($_POST['friends']) {
$friends = $_POST['friends'];
} else {
$friends = FALSE;
}
You need to open your php.ini
file and set (or create) this line:
max_input_vars = 1000000
max_input_vars
has a default value of 1000, which will cut off an array at 1000 total elements. Just change it to a really high number (in my case, I needed to set it to one million).
From the PHP Manual:
Keep in mind: As the manual says, this default limit was put in place to prevent denial of service attacks.
Hope this helps even though this is an old question.
这篇关于阵列被砍掉了阿贾克斯后结束。阿贾克斯发布的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!