I am trying to print the name of the downloaded files, but for some reason it only prints the first file.
The script allows you to load unlimited files and why an array of arrays.
$(document).on('submit', 'form', function(e) {
e.preventDefault();
var $form = $(this);
var act = 'add';
var files = $form.find('.file-field').prop('files');
var names = "";
$.each(files,function(i, file){
name = file.name;
alert(name);
});
});
HTML
<form class="form-horizontal" action='#' method="post" enctype="multipart/form-data">
<input type='file' name='file[]' class=' form-control file-field multi' maxlength='2' accept="image/jpg,image/png,image/jpeg,image/gif" id="uploadFile0"/>
<button class="btn btn-primary submit" >SEND</button>
</form>
Roi source
share