zoukankan      html  css  js  c++  java
  • uploadify上传带参数及接收参数的方法

    function uploadify() {
            $("#uploadify").uploadify({
                method:'post',
                uploader: '/Manage/Order/SubmitUploadify',
                swf: '/Content/scripts/plugins/uploadify/uploadify.swf',
                buttonText: "上传文件",
                height: 30,
                 110,
                fileTypeExts: '*.jpg;*.doc;*.docx;*.pdf;*.png',
                fileSizeLimit: '10MB',
                multi: false,
                formData: "ContractCode":"20170222","UserId":"20125"
                },
                onUploadStart: function (file) {
                    some code...
                },
                onUploadSuccess: function (file, data, response) {
                    var obj = jQuery.parseJSON(data); 
                    if (obj.State) {
                        $("#ContractFile").val(obj.FilePath);
                    }
                },
                onUploadError: function (file) {
                    $("#" + file.id).prepend('<span class="error" title="失败"><i class="fa fa-exclamation-circle"></i></span>');
                }
            });
            $("#uploadify-button").prepend('<i style="opacity: 0.6;" class="fa fa-cloud-upload"></i>&nbsp;');
        }

    参数主要在:formData: "ContractCode":"20170222","UserId":"20125" 位置

    接收参数方法:

    [HttpPost]
    public ActionResult SubmitUploadify(HttpPostedFileBase fileData,string contractCode,string userId)
    {
       string formatFilePath = string.Format("~/Uploads/ContractFile/{0}", contractCode);
       ResultUpload rst = UploadHelper.Uploadify(fileData, formatFilePath);
       return Content(rst.ToJson());
    }
  • 相关阅读:
    Nightwatch的介绍
    reduce的用法及实例
    什么是声明式渲染?
    H5自带的表单验证
    Flex弹性布局
    JS中的forEach,for in,for of和for的遍历优缺点及区别
    将博客搬至CSDN
    9 外观模式(Facade)
    8 代理模式(Proxy)
    7 装饰模式(Decorator)
  • 原文地址:https://www.cnblogs.com/firstcsharp/p/6430094.html
Copyright © 2011-2022 走看看