$ ("#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 </A></TD><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