I'm facing problem with multiple fileupload.
The problems are:
If i upload 2
files
only 1 file being sent to backend.Only last file is sent to server (skipping other files, in other words only 1 file sent to backend)
Question: I have a situation where on each input i can browse multiple files and can click on submit. I'm expect every file should be sent to server.
Here: Is jsfiddle
showing my problem: http://jsfiddle.net/eabangalore/jyteus6c/2/
Note: Please the console.log
to check whether all files
sent to server or not.
Below is my code:
var filesUploadList = [];
function initializeMultipleFileUpload(){
fileList.forEach(function(obj){
$('input[data-id="'+obj.identifier+'"]').fileupload({
url: 'https://jsonplaceholder.typicode.com/posts',
autoUpload: false,
maxChunkSize: 10*1024*1024, // 1MB
maxRetries: 10,
dataType: 'json',
multipart: false,
sequentialUploads: true,
replaceFileInput: false,
progress: function(e,data){
console.log('Progress for file Name: ',data.data.name);
},
}).on("fileuploadadd", function (e, data) {
filesUploadList.push(data.files[0])
});
});
}
var fileList = [
{'fileNo':1,identifier:111},
{'fileNo':2,identifier:222},
{'fileNo':3,identifier:33}
];
var inputFileStr = '';
for(var i = 0; i< fileList.length; i++){
inputFileStr += '<input type="file" multiple data-id="'+fileList[i].identifier+'"><button data-buttonid="'+fileList[i].identifier+'" class="comm-submit-btn">submit</button>';
}
$('#multiplefiles').html(inputFileStr);
initializeMultipleFileUpload(); //initialize fileupload here
$(document).ready(function () {
$(".comm-submit-btn").click(function () {
var fileUploadInputId = $(this).attr('data-buttonid');
console.log('.....filesUploadList.........',filesUploadList);
$('input[data-id="'+fileUploadInputId+'"]').fileupload('send', {files: filesUploadList });
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/10.2.0/js/jquery.iframe-transport.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/10.2.0/js/jquery.fileupload.min.js"></script>
<div id="multiplefiles">
</div>
any please help me still i'm unable to proceed further
Please help me thanks in advance!!!!!!
chunk
upload – Hbeam