我可以在一个数组中调用我所有的多个文件,它可以存储在一个特定的文件夹中,例如。“./文件/”。
Code for my form:
<form id="Student" name="Student" method="post" action="uploaded.php" enctype="multipart/form-data">
<input name="upload[]" id="Assign" type="file"/>
<input name="upload[]" id="Testpapers" type="file"/>
<input name="upload[]" id="others" type="file"/>
<input type="submit" name="submit" value="Submit">
Code for uploaded.php:
$number_of_uploaded_files = 0;
for ($i = 0; $i < count($_FILES['upload']['name']); $i++)
{
if ($_FILES['upload']['name'][$i] != '')
{
$dir = "documents/";
$number_of_uploaded_files++;
$uploaded_files[] = $_FILES['upload']['name'][$i];
move_uploaded_file($_FILES['upload']['tmp_name'][$i], $dir. $_FILES['upload']['name'][$i])
}
是否可以将它们分别存储在不同的文件夹中?就像将它们存储在“documents/assign”然后“documents/testpapers”中。我想不出一个想法来检测数组索引是否属于分配或试卷,其他人。