Hey I am uploading files to a chosen folder and right now I have the ability to select and upload just one file. I know how to handle multiple files in php but I am not sur
First you have to use "multiple" attribute with input tag. Like
Then in Javascript onChange function -
var data = new FormData();
var imgData = document.getElementById('fileUpload');
for (var i = 0; i < imgData.files.length; i++) {
data.append('my_file[]', imgData.files[i], imgData.files[i].name);
}
//now call ajax
$.ajax({
url: "upload.php",
type: "POST",
data: data,
enctype: 'multipart/form-data',
processData: false, // tell jQuery not to process the data
contentType: false // tell jQuery not to set contentType
}).done(function( data ) {
console.log("PHP Output:");
console.log( data );
alert("upload success!")
});
And your file will be uploaded