I’m able to call out all my multiple files in an array and it can be able to be stored in a specific folder for eg. “./documents/”.
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])
}
Is it possible to store them in different folders respectively? Like store them inside “documents/assign” then “documents/testpapers”. I can’t think of an idea to detect array index belongs to assign or testpapers, others.
idwon’t pass to the server side.But you could assign the key like below.
In server side, you could use
foreachto loop it.