阵列被砍掉了阿贾克斯后结束。阿贾克斯发布的限制?阵列、结束、阿贾克斯后、阿贾克斯

2023-09-11 00:36:33 作者:疲惫无力的心

我有一个多维数组,它由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手册:

  

多少个输入变量可以被接受的(限制适用于$ _GET,   $ _ POST和$ _COOKIE超全局另发)。使用此指令   减轻拒绝服务攻击而使用散列的可能性   碰撞。如果有比由该指定的多个输入变量   指令,则发出E_WARNING,并且进一步输入变量是   从请求截断。 此限制只适用于每一个嵌套   一个多维输入阵列的水平。的

请注意:作为手册上说,这个缺省限制是落实到位,以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:

How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). Use of this directive mitigates the possibility of denial of service attacks which use hash collisions. If there are more input variables than specified by this directive, an E_WARNING is issued, and further input variables are truncated from the request. This limit applies only to each nesting level of a multi-dimensional input array.

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.