LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

Is there an example code for multiple files upload? #217

Open Julianoe opened 5 years ago

Julianoe commented 5 years ago

Trying to implement a multi files upload but the progress bar is either deleted or not found or not updated properly. I wondered if someone had an example for multi upload configuration.

I read that it was discussed several years ago but could not find anything: https://github.com/LPology/Simple-Ajax-Uploader/issues/5

I'm looking to allow multiple files upload, either uploading at the same time or in a queued order it does not matter for me.

edit: just so my message is clearer: i edited the basic example and added "multiple: true" ans "multipleSelect: true". It works well, the files are uploaded, but the progressbar and result message only display for one file.

Wesley-GONG commented 4 years ago

here is working code, copy from my project var btnfile = $("#btn_file"); var uploader = new ss.SimpleUpload({ button: btnfile, url: uploadUrl, name: 'uploadfile', allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'mp4', 'pdf', 'doc', 'docx', 'zip'], responseType: 'json', maxSize: 2048, multiple: true, multipleSelect: true, autoSubmit: true, onSizeError: function () { this.removeCurrent(); alert("Size Error, 2Mb MAX"); }, onSubmit: function () { //this.removeCurrent(); }, onComplete: function (filename, response) { console.log('onComplete,' + filename); if (!response) { alert('upload failed'); return false; } alert('Upload OK'); //do something }, onError: function (filename, errorType, status, statusText, response, uploadBtn, fileSize) { alert(filename + '/' + errorType + '/' + status + '/' + statusText + '/' + response + '/' + uploadBtn + '/' + fileSize); } });