<form action="<?$_SERVER["PHP_SELF"]?>" method="post" enctype="multipart/form-data">
Send these files:<br />
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" value="Send files" />
</form>
When the above form is submitted, the arrays $FILES['userfile'], $FILES['userfile']['name'], and $_FILES['userfile']['size'] will be initialized .
But when I use foreach() it doesnt work :
<?
foreach($_FILES["userfile"]["name"] as $key=>$value){
move_uploaded_file($_FILES["userfile"]["tmp_name"][$key],
"upload/" . $value);
}
?>
It said "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\php\test.php on line 9" ;
Could you explain for me about my errors?
Thank much 🙂