uploadify 3.2 后台动态传参数

            最近在弄一个上传的小功能,需要往后台传递一些动态参数,网上有一些传参数可能是因为版本不对也没成功。仔细看了官网的一些说明,搞定了。

            3.2中传递参数用的的是'formData':{'somekey':'somevalue'}这个属性,但其不能传递动态参数;动态传参需要用到settings这个方法,官网上也说明了。示例如下:

         

    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 },//这里只能传静态参数
                //'fileTypeExts': '*.rar;*.zip;*.7z;*.jpg;*.jpge;*.gif;*.png',
                'onSelectError': function (file, errorCode, errorMsg) {
                    switch (errorCode) {
                        case -100:
                            alert("上传的文件数量已经超出系统限制的" + jQuery('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件!");
                            break;
                        case -110:
                            alert("文件 [" + file.name + "] 大小超出系统限制的" + jQuery('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小!");
                            break;
                        case -120:
                            alert("文件 [" + file.name + "] 大小异常!");
                            break;
                        case -130:
                            alert("文件 [" + file.name + "] 类型不正确!");
                            break;
                    }
                },
                'onClearQueue': function (queueItemCount) {
                    alert("取消上传");
                    return;
                },
                'onQueueComplete': function (queueData) {
                    alert("文件上传成功!");
                    return;
                },
                'onUploadStart': function (file) { $("#file_upload").uploadify("settings", "formData", { 'ctrlid': ctrlid });
                 //在onUploadStart事件中,也就是上传之前,把参数写好传递到后台。
                }
            });
        });


后台取得参数的话,可以用context.Request.Form["ctrlid"] 来取得。

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值