AjaxFileUpload multi-File Upload

Source: Internet
Author: User

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 ');}});


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.