gpt4 book ai didi

php - 多文件上传字段选项不上传所有文件

转载 作者:行者123 更新时间:2023-11-28 03:31:20 25 4
gpt4 key购买 nike

我正在使用输入 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,最大帖子大小 8m 和最大文件大小 128m 以及总大小我尝试上传的所有文件中有 1.94 兆

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 ) ) 

最佳答案

你的数组中共有 20 个文件,分为 5 个子数组,根据你在问题中所说的,这是你的上传限制。

I checked the PHP info and it says max file uploads 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];
}
}

关于php - 多文件上传字段选项不上传所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17560645/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com