Home > Web Front-end > JS Tutorial > How the ajaxFileUpload.js plug-in supports multiple file uploads_javascript skills

How the ajaxFileUpload.js plug-in supports multiple file uploads_javascript skills

WBOY
Release: 2016-05-16 16:38:06
Original
1306 people have browsed it

Prerequisite:

ajaxFileUpload.js plug-in multi-file upload

Steps:

1. Modify the source code (the source code only supports the upload of a single file):

Copy code The code is as follows:

//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);
//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:
Copy code The code is as follows:

$.ajaxFileUpload({
url: "./upload/upload.action",
secureuri : false,
//fileElementId:'uploadfile1',//original usage
fileElementId: ['uploadfile1','uploadfile2','uploadfile3','uploadfile4','uploadfile5'],//Current usage
dataType : 'json',
success : function(data) {
ajaxLoadEnd();
if (data.result == "success") {
$.messager.alert('Message','Import successful.','info');
} else {
$('#import_right').dialog('open');
$.messager.alert('Message','Import failed.
Error message:' data.message,'error');
}
},
error: function(data, status, e)
{
ajaxLoadEnd();
$.messager.alert('Message','Import failed.
Error message: Network exception or form data error.','error');
}
});
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template