Upload multiple files using ajaxFileUpload with different file identifiers

I am trying to upload multiple files in the same form. Multiple files must be in different fields. I used ajaxfileuploader for a single file and got it using MultipartHttpServletRequest. And it was successful.

I used

$.ajaxFileUpload ( { url: 'uploadfile', secureuri: false, fileElementId:'setup', dataType: 'text', data: { id: id }, success: function (data, status) { if (status == 'success') { return; } else { } }, error: function (data, status, e) { return alert('Error ! Failed to upload file!'); } } ) 

But my problem is that I have many files to download on a single request. For example setup1, setup2, setup3 (different identifiers). How to specify multiple identifiers on ajaxFileUpload? Your kind reply is welcome.

thanks

0
javascript jquery spring ajax file-upload
source share
2 answers

You can wrap this code in a function and call it several times, since the plugin does not support several elements at a time.

 var uploadFile = function (elementID) { $.ajaxFileUpload({ url: 'uploadfile', secureuri: false, fileElementId: elementID, dataType: 'text', data: { id: id }, success: function (data, status) { if (status == 'success') { return; } else {} }, error: function (data, status, e) { return alert('Error ! Failed to upload file!'); } }); }; 

Then use it that way

 uploadFile('file1'); uploadFile('file12'); 
0
source share

Suppose to use this jQuery plugin for multiUpload. http://hayageek.com/docs/jquery-upload-file.php

0
source share

All Articles