I have been stuck at this for so long, I finally gave up and decided to ask help from here
I have researched multiple topics on blueimp here but none of the solutions have worked for me
materials that I've tried
Uploading multiple files from multiple input fields programatically - blueimp jquery fileupload
including topics covered in there, also
jQuery File Upload not working when file input dynamically created
etc
My problem is that project that I'm working on uses MultiFile.js (https://github.com/fyneworks/multifile) alongside with blueimp file uploader
What multifile.js does is it dynamically creates new inputs for files and hides those where input has been added.
I've been at it for days now but Blueimp file uploader only takes the initial input, uploads only that one file and add method ignores all other input fields. Here is my code so far
$(function() {
'use strict';
$(window).on('change', function(e) {
var form = $("form");
var multiPartAttribute = 'multipart/form-data';
form.attr('enctype', multiPartAttribute).attr('encoding', multiPartAttribute);
var barContainer = $('#container-upload-prg');
var bar = barContainer.find('#inner-upload-prg');
var pushButton = $("#saveMat");
form.fileupload({
dataType: 'json',
replaceFileInput: false,
autoUpload: false,
add: function(e, data) {
pushButton.off('click').on('click', function() {
barContainer.css("display", "inline-block");
data.submit();
});
},
done: function(e, data) {
barContainer.css("display", "none");
var result = data.result;
if (result.ok == true) {
$('#MaterialSuccessText').html(result.message);
$(".close").click();
} else if (result.ok == false) {
$('#MaterialErrorText').html(result.message);
}
},
progressall: function(e, data) {
var percent = parseInt(data.loaded / data.total * 100, 10);
bar.css('width', percent + '%');
bar.text(percent + '%');
},
submit: function (e, data) {
var formData = $("form").find(':hidden, :text, textarea').serializeArray();
formData.push({ name: '__EVENTTARGET', value: 'do_save_files' });
data.formData = formData;
}
});
};
}).trigger('change');
});