For alternative solution, you can using HTML5 multiple-upload,
HTML
set attribute multiple for your input-file, check this link https://developer.mozilla.org/en-US/docs/Web/API/Input.multiple
<form id="form-upload">
<input type="file" name="upload" id="upload" multiple>
</form>
JS
to upload file using juery, you can use form-data : https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects
$('#upload').bind("change", function(){
var formData = new FormData($("#form-upload")[0]);
//loop for add $_FILES["upload"+i] to formData
for (var i = 0, len = document.getElementById('upload').files.length; i < len; i++) {
formData.append("upload"+(i+1), document.getElementById('upload').files[i]);
}
//send formData to server-side
$.ajax({
url : "process_upload.php",
type : 'post',
data : formData,
dataType : 'json',
async : true,
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
error : function(request){
console.log(request.responseText);
},
success : function(json){
//place your code here
}
});
});
SERVER-SIDE(ex:PHP)
//just print $_FILES
print_r($_FILES);