I have more than one input which are of type file
<form name="vform" method="post" enctype="multipart/form-data" >
<input type=file name='thumbs1' />
<input type=file name='thumbs2' />
<input type=file name='thumbs3' />
... etc
</form>
let say i got the count of file input=3
$i = 1;
while($i <= 3)
{
$thumb = "thumbs".$i;
$fileName = $_FILES['$thumb']['name'];
$tmpName = $_FILES['$thumb']['tmp_name'];
$filePath = "directory/";
if(move_uploaded_file($tmpName, $filePath)){echo " ";}else{echo " ";}
$i++;
}
What happens here is that only the first one got the filename, but not one of them move to the expected directory or anywhere else.
Is there a specific way to declare when dealing with multiple file input?
Remove the single quotes from
$_FILES['$thumb']and change it to$_FILES[$thumb]PHP will not parse variables within the single quotes
' '.On
move_uploaded_filefunction you need to specify the file name for destination before moving