Recently in a small upload function, you need to pass some dynamic parameters, online some parameters may be because the version is not successful. Carefully read the official website of some instructions, done.
3.2 passed the parameter is ' FormData ': {' somekey ': ' somevalue '} This property, but it can not pass dynamic parameters, dynamic parameter needs to use the method of settings, official online also explained. Examples are as follows:
[JavaScript]View PlainCopy
- JQuery (document). Ready (function () {
- var ctrlid = getquerystring ("Ctrlptid");
- JQuery ("#file_upload"). Uploadify ({
- ' buttonimage ': '/uploadify/browse-btn.png ',
- ' auto ': false,
- ' successtimeout ': 99999,
- ' swf ': '/uploadify/uploadify.swf ',
- ' Queueid ': ' uploadfilequeue ',
- ' uploader ': '/uploadify/uploadhandler.ashx ',
- ' filesizelimit ': ' 0 ',
- ' filetypeexts ': ' *.gif; *.jpeg; *.jpg; *.png ',
- ' Multi ': false,
- ' Queuesizelimit ': 5,
- ' progressdata ': ' speed ',
- ' overrideevents ': [' Ondialogclose '],
- //' FormData ': {' somekey ': ' somevalue ', ' CtrlId ': 2},//only static parameters can be passed here
- //' filetypeexts ': ' *.rar;*.zip;*.7z;*.jpg;*.jpge;*.gif;*.png ',
- ' onselecterror ': function (file, ErrorCode, errormsg) {
- switch (errorCode) {
- case-100:
- Alert ("The number of uploaded files has exceeded the system limit" + jQuery (' #file_upload '). Uploadify (' Settings ', ' queuesizelimit ') + " A file! ");
- Break ;
- case-110:
- Alert ("file [" + File.name + "] size exceeds system limit" + jQuery (' #file_upload '). Uploadify (' Settings ', ' Filesizelimit ') + "Size! ");
- Break ;
- case-120:
- Alert ("file [" + File.name + "] size is abnormal! ");
- Break ;
- case-130:
- Alert ("file [" + File.name + "] type is incorrect! ");
- Break ;
- }
- },
- ' onclearqueue ': function (queueitemcount) {
- Alert ("Cancel upload");
- return;
- },
- ' onqueuecomplete ': function (queuedata) {
- Alert ("File upload succeeded!") ");
- return;
- },
- ' Onuploadstart ': function (file) {
- $ ("#file_upload"). Uploadify ("settings", "FormData", { ' ctrlid ': CtrlId});
- //In the Onuploadstart event, that is, before uploading, the parameters are written to the backstage.
- }
- });
- });
Background to obtain parameters, you can use the context. request.form["CtrlId"] to obtain.
Uploadify 3.2 Background Dynamic transfer parameters