Skip to content

Instantly share code, notes, and snippets.

@hemache
Forked from abdualrhman1410/upload.php
Created December 11, 2012 15:34
Show Gist options
  • Save hemache/4259398 to your computer and use it in GitHub Desktop.
Save hemache/4259398 to your computer and use it in GitHub Desktop.
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
<?
$num_files = 5;
while($num_files){
echo '<input type="file" name="file[]" /> <br>';
$num_files --;
}
?>
<input type="submit" name="upload" />
</form>
<?
if($_POST['upload']){
for($i=1;$i<=5;$i++){
$dir="uploads/".$_FILES['file_'.$i]['name'];
if($_FILES['file_'.$i]['error']==0){
$move=move_uploaded_file($_FILES['file_'.$i]['tmp_name'], $dir);
if($move){
echo "uploaded file".$dir;
}else{
echo $_FILES['file_'.$i]['error'];
}
}else{
echo "no select file <br>";
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment