我有以下代码可以工作和上传,但它不会循环通过数组来上传每个文件,只是第一个文件。
<form method="post" enctype="multipart/form-data" action="http://<?php echo $pageURL;?>">
<input class="new" multiple="multiple" name="documents[]" type="file" />
<input class="new" multiple="multiple" name="documents[]" type="file" />
<input type="submit" class="button" name="addMaterials" value="Add" />
<?php
foreach($_FILES['documents']['tmp_name'] as $key => $tmp_name)
{
$file_name = $key.$_FILES['documents']['name'][$key];
$file_size =$_FILES['documents']['size'][$key];
$file_tmp =$_FILES['documents']['tmp_name'][$key];
$file_type=$_FILES['documents']['type'][$key];
move_uploaded_file($file_tmp,"files/".time().$file_name);
}
?>
我需要它来循环浏览我的文档 [] 文件数组。
文档数组的示例print_r()
:
Array (
[name] => Array ( [0] => AcroRd32.exe )
[type] => Array ( [0] => application/x-msdownload )
[tmp_name] => Array ( [0] => C:\xampp\tmp\phpE8BD.tmp )
[error] => Array ( [0] => 0 )
[size] => Array ( [0] => 1343112 )
)
任何帮助表示赞赏。