I am trying to upload multiple files with single browse button, but I couldn't got success through it . I tried suggestion mentioned in similar query. Below code is only uploading one file, I need to upload more than file with same browse button.
Any idea what is wrong in the code?
<html>
<body>
<form enctype="multipart/form-data" action="uploadj.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile[]" type="file" multiple /><br />
<p>
<input type="submit" name="button" id="button" value="Submit">
</p>
</form>
</html>
</body>
Php Code :
<?php
$get_folder = $_POST['textfield'];
mkdir ("/opt/lampp/htdocs/test_upload/" . $get_folder, 0777);
echo "Analysis Directory created successfully";
$target_path = "$get_folder/";
for($i=0;$i < count($_FILES['uploadedfile']['name']);$i++){
$target_path = $target_path . basename( $_FILES['uploadedfile']['name'][$i]);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$i], $target_path))
{
echo "The file has been uploaded";
} else
{
echo "There was an error uploading the file, please try again!";
}
}
?>
Thanks !