0

I want to make it so when uploading multiple files to a target folder you don't only have one choose file option, but rather multiple choose file options to upload as many as needed at once. It targets a folder within it's directory and when I have one choose file input it works, but when more are added it doesn't work. Here is my code so far.

<html> 
<head>
<?php
if(isset($_POST['Submit']))
{
$file_name = $_FILES['audio_file']['name'];

if($_FILES['audio_file']['type']=='audio/mpeg' || $_FILES['audio_file']['type']=='audio/mpeg3' || $_FILES['audio_file']['type']=='audio/x-mpeg3' || $_FILES['audio_file']['type']=='audio/mp3' || $_FILES['audio_file']['type']=='audio/x-wav' || $_FILES['audio_file']['type']=='audio/wav')
{ 
 $new_file_name=$_FILES['audio_file']['name'];

 $target_path = "audiofiles/".$new_file_name;

if(move_uploaded_file($_FILES['audio_file']['tmp_name'], $target_path)) {

}
}
}

?>
</head>
<body>

<form name="audio_form" id="audio_form" action="" method="post" enctype="multipart/form-data">
<fieldset style="height: 23vh; width: 50vw;">

<input name="audio_file" id="audio_file" type="file" style="position: fixed; top: 2vh;">

<input name="audio_file" id="audio_file" type="file" style="position: fixed; top: 7vh;">

<input name="audio_file" id="audio_file" type="file" style="position: fixed; top: 12vh;">

<input name="audio_file" id="audio_file" type="file" style="position: fixed; top: 17vh;">

<input name="audio_file" id="audio_file" type="file" style="position: fixed; top: 22vh;">

<input type="submit" name="Submit" id="Submit" value="Submit" style="position: fixed; top: 30vh;">
</fieldset>
</form>

</body> 
</html>
Devin
  • 30
  • 5
  • 1
    Possible duplicate of [Multiple file upload in php](http://stackoverflow.com/questions/2704314/multiple-file-upload-in-php) – izk May 09 '16 at 20:09
  • heey sir, I've seen this question posted alot about file upload and see [here](http://stackoverflow.com/questions/2704314/multiple-file-upload-in-php) for older stackoverflow posts with very good explanation, good luck further. – izk May 09 '16 at 20:10

1 Answers1

0

you could try name + []

<input name="audio_file[]" id="audio_file" type="file" style="position: fixed; top: 2vh;">

or use the property multiple

<input name="audio_file" id="audio_file" type="file" style="position: fixed; top: 2vh;" multiple>

and than cycle in your php code through the files

M4tho
  • 116
  • 2
  • 13