How the jquery upload component dynamically binds parameters to the background

Source: Internet
Author: User
Tags rar

 $ ("#upload_photo"). Uploadify ({' auto ': false, ' method ': ' Post ', ' height ': 20, ' Width ': +, ' swf ': ' <%=basepath%>js/uploadify.swf ', ' uploader ': ' <%=basepath%>atta Ch/api/upload ', ' filetypedesc ': ' Format: txt,xls,xlsx,doc,docx,rar,zip,jpg,png,pdf ',//description ' Filetypeext S ': ' *.txt;*.xls;*.xlsx;*.doc;*.docx;*.rar;*.zip;*.jpg;*.png;*.pdf ',//File type ' filesizelimit ': ' 30000KB ',//File Size ' buttontext ': ' Select File ',//button name ' fileobjname ': ' uploadify ', ' mul            Ti ': True, ' successtimeout ': 5, ' requeueerrors ': false, ' removetimeout ': 1,                  ' removecompleted ': true, ' onselecterror ': function (file,errorcode,errormsg) {alert ("failed"); if (errorcode==-110) {THIS.QUEUEDATA.ERRORMSG = "file is too large to upload!"                  "; }}, ' <spAn style= "color: #ff0000; Background-color:rgb (255, 255, 255);"             ><strong>onuploadstart ': function (file) {////Dynamic binding parameter is passed to the background var groupname=$ (". Select2"). Val ();             $ (' #upload_photo '). Uploadify (' Settings ', ' FormData ', {' GroupName ': GroupName}); },</strong></span> ' onuploadsuccess ': function (file, data, response) {var attachs =              Jquery.parsejson (data);              var attach=attachs.result[0];                        alert (ATTACH2); if (attach.id!=null) $ ("#tbfj tbody"). Append ("<tr name=\" "+attach.id+" \ "><td>" +attach.filename+ "</td><td>" +attach.filesize+ "</td><td>" +attach.uploaddate+ "</td><td><a Href=\ "${pagecontext.request.contextpath}/attach/api/download/" +attach.id+ "\" > Download &LT;/A&GT;&LT;/TD&GT;&LT;TD         ><a class=\ "del\" > Delete </a></td></tr> "); },                });

Dynamic pass-through parameters need to be implemented in the Red section:

1, first add the Onuploadstart function, set the parameters at the beginning of the upload

2, through $ (' #upload_photo '). Uploadify (' Settings ', ' FormData ', {' GroupName ': GroupName}); setting parameters

Description: Settings: Manipulating the name, representing the settings for uploading

FormData: cannot be changed, indicating that parameters will be added to the form data

{' GroupName ': groupName}: Parameters passed to the background, {Key:value,.....}

How the jquery upload component dynamically binds parameters to the background

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.