我有以下 print_r,它源自“多个(不是错字)文件上传”。
Array
(
[file] => Array
(
[name] => Array
(
[1] => Array
(
[0] => IMG_8502 f 5 .jpg
[1] => IMG_8507 f 5 .jpg
)
[2] => Array
(
[0] => IMG_8508 f 5 .jpg
[1] => IMG_8529 f 5 .jpg
[2] => IMG_8612 fff 5 .jpg
)
[3] => Array
(
[0] => IMG_8502 f 5 .jpg
[1] => IMG_8507 f 5 .jpg
)
)
[type] => Array
(
[1] => Array
(
[0] => image/jpeg
[1] => image/jpeg
)
[2] => Array
(
[0] => image/jpeg
[1] => image/jpeg
[2] => image/jpeg
)
[3] => Array
(
[0] => image/jpeg
[1] => image/jpeg
)
)
[tmp_name] => Array
(
[1] => Array
(
[0] => C:\wamp\tmp\php1CC.tmp
[1] => C:\wamp\tmp\php1FC.tmp
)
[2] => Array
(
[0] => C:\wamp\tmp\php23B.tmp
[1] => C:\wamp\tmp\php26B.tmp
[2] => C:\wamp\tmp\php2AB.tmp
)
[3] => Array
(
[0] => C:\wamp\tmp\php2CB.tmp
[1] => C:\wamp\tmp\php30A.tmp
)
)
[error] => Array
(
[1] => Array
(
[0] => 0
[1] => 0
)
[2] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
[3] => Array
(
[0] => 0
[1] => 0
)
)
[size] => Array
(
[1] => Array
(
[0] => 2776165
[1] => 2380025
)
[2] => Array
(
[0] => 2456713
[1] => 2585779
[2] => 1770128
)
[3] => Array
(
[0] => 2776165
[1] => 2380025
)
)
)
)
<?php
if(isset($_FILES['file'])=== true){
$files = $_FILES['file'];
for($x = 0; $x < count($files['name'][$x]); $x++){
$file_name = $files['name'][$x];
$tmp_name = $files['tmp_name'][$x];
move_uploaded_file($tmp_name, 'documents/'.$file_name);
}}?>
我想我需要嵌入另一个 for 循环来访问实际名称和 tmp 数组... name1、name2、name3。我希望能够访问每个子数组,以便可以相应地移动它们