多个文件上载字段选项不上传所有文件

时间:2013-07-10 00:41:30

标签: php html upload

我正在使用输入type="file" multiple="multiple"和PHP上传循环。

<input name="data[]" id="file" type="file" multiple="multiple" class="txtinput2" />

上面是我的HTML,下面是我的PHP:

if(isset($_POST['action'])=='uploadfiles'){
$count_data=count($_FILES['data']) ;   ######### count the data #####

for($x=0;$x<$count_data;$x++)

当我回复count_data时,它会给我输出 5 ,但当我选择 28 文件时,它会显示 28 个文件在输入字段中选择。 multiple="multiple"仅支持 5 上传吗?

我检查了PHP信息,它说最大文件上传 20 ,最大帖子大小 8米,最大文件大小 128米以及总大小我尝试上传的所有文件都是 1.94 megs

Array ( [name] => Array ( [0] => DSCF0960.jpg [1] => DSCF0961.jpg [2] => DSCF0963.jpg [3] => DSCF0964.jpg [4] => DSCF0966.jpg [5] => DSCF0967.jpg [6] => DSCF0968.jpg [7] => DSCF0969.jpg [8] => DSCF0970.jpg [9] => DSCF0971.jpg [10] => DSCF0972.jpg [11] => DSCF0973.jpg [12] => DSCF0974.jpg [13] => DSCF0975.jpg [14] => DSCF0976.jpg [15] => DSCF0977.jpg [16] => DSCF0978.jpg [17] => DSCF0979.jpg [18] => DSCF0980.jpg [19] => DSCF0981.jpg ) [type] => Array ( [0] => image/jpeg [1] => image/jpeg [2] => image/jpeg [3] => image/jpeg [4] => image/jpeg [5] => image/jpeg [6] => image/jpeg [7] => image/jpeg [8] => image/jpeg [9] => image/jpeg [10] => image/jpeg [11] => image/jpeg [12] => image/jpeg [13] => image/jpeg [14] => image/jpeg [15] => image/jpeg [16] => image/jpeg [17] => image/jpeg [18] => image/jpeg [19] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/php4uI9g8 [1] => /tmp/phpVx5WrZ [2] => /tmp/php2DbRCQ [3] => /tmp/phpT2gSNH [4] => /tmp/phpPDlZYy [5] => /tmp/phpMzCcaq [6] => /tmp/phpRxkwlh [7] => /tmp/phpgoRWw8 [8] => /tmp/phpYlGsIZ [9] => /tmp/phpYBG1TQ [10] => /tmp/phpTQBD5H [11] => /tmp/phpQesphz [12] => /tmp/php5U4dtq [13] => /tmp/phpp2G5Eh [14] => /tmp/phpwaZZQ8 [15] => /tmp/php4W0W2Z [16] => /tmp/php7g3WeR [17] => /tmp/phpeZj0qI [18] => /tmp/phpAGo6Cz [19] => /tmp/phpbXlfPq ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 0 [16] => 0 [17] => 0 [18] => 0 [19] => 0 ) [size] => Array ( [0] => 79605 [1] => 75839 [2] => 71245 [3] => 63228 [4] => 64201 [5] => 74440 [6] => 75350 [7] => 73367 [8] => 72491 [9] => 69725 [10] => 75508 [11] => 72755 [12] => 76076 [13] => 72140 [14] => 68745 [15] => 77859 [16] => 74281 [17] => 74613 [18] => 71702 [19] => 75916 ) ) 

1 个答案:

答案 0 :(得分:0)

您的阵列中共有20个文件,分为5个子阵列,根据您在问题中所说的内容,您的上传限制为。

  

我检查了PHP信息,它说最大文件上传20

第一个数组是每个文件的旧文件名。
第二个数组是按顺序的每个文件的文件类型 第三个数组是保存文件的位置及其临时名称 第四个数组是如果任何文件无法上传或不上传,我认为它将是0或1为0没有错误 最后一个数组是按顺序的每个文件的文件大小。

使用以下方法计算所有文件:

$count_data=count($_FILES['data']['name']) -1;

并按照以下方式阅读:

for($i=0; $i < $count_data; $i++)
{
    if ($_FILES['data']['error'][$i] == 0)
    {
        $name = $_FILES['data']['name'][$i];
        $temp = $_FILES['data']['tmp_name'][$i];
        $type = $_FILES['data']['type'][$i];
        $size = $_FILES['data']['size'][$i];
    }
}