AjaxFileUpload multi-File Upload
Prerequisites:
Multi-File Upload using the ajaxFileUpload. js plug-in
Steps:
1. Modify the source code (the source code only supports uploading a single file ):
// Modify the pre-code ------- // var oldElement = jQuery ('#' + fileElementId); // var newElement = jQuery (oldElement ). clone (); // jQuery (oldElement ). attr ('id', fileId); // jQuery (oldElement ). before (newElement); // jQuery (oldElement ). appendTo (form); // code before modification ------- // modified code ------- for (var I in fileElementId) {var oldElement = jQuery ('#' + fileElementId [I]); var newElement = jQuery (oldElement ). clone (); jQuery (oldElement ). attr ('id', fileId); jQuery (oldElement ). before (newElement); jQuery (oldElement ). appendTo (form);} // modified code -------
2. Usage:
$. AjaxFileUpload ({url :". /upload. action ", secureuri: false, // fileElementId: 'uploadfile1', // original usage method: fileElementId: ['uploadfile1', 'uploadfile2', 'uploadfile3', 'uploadfile4 ', 'uploadfile5'], // The current usage method dataType: 'json', success: function (data) {ajaxLoadEnd (); if (data. result = "success") {$. messager. alert ('info', 'import successful. ', 'Info');} else {$ (' # import_right '). dialog ('open'); $. messager. alert ('info',' import failed.
Error message: '+ data. message, 'error') ;}}, error: function (data, status, e) {ajaxLoadEnd (); $. messager. alert ('info', 'import failed.
Error message: network exception or form data error. ', 'Error ');}});