Prerequisites:
ajaxFileUpload.js plugin multiple file upload
step:
1. Modify the source code (the source code only supports the upload of a single file):
The code copy is as follows:
//The code before modification --------
//var oldElement = jQuery('#' + fileElementId);
//var newElement = jQuery(oldElement).clone();
//jQuery(oldElement).attr('id', fileId);
//jQuery(oldElement).before(newElement);
//jQuery(oldElement).appendTo(form);
//The 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. How to use:
The code copy is as follows:
$.ajaxFileUpload({
url : "./upload/upload.action",
secureuri : false,
//fileElementId:'uploadfile1',//Original usage method
fileElementId: ['uploadfile1','uploadfile2','uploadfile3','uploadfile4','uploadfile5'],//Now use method
dataType : 'json',
success : function(data) {
ajaxLoadEnd();
if (data.result == "success") {
$.messager.alert('Information','Imported successfully.','info');
} else {
$('#import_right').dialog('open');
$.messager.alert('Information','Import failed.<br>Error message: '+data.message,'error');
}
},
error : function(data, status, e)
{
ajaxLoadEnd();
$.messager.alert('Information','Import failed.<br>Error message: Network exception or form data error.','error');
}
});