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> '); }
参数主要在: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()); }