uploadify使用教程

1              <div>
2                 <input type="file" id="uploadify" name="uploadify" />
3             </div>
4             <div>
5                 <a href="javascript:$('#uploadify').uploadify('upload');">上传</a>
6             </div>            

js

 1  $(function () {
 2         $('#uploadify').uploadify({
 3             width: 60,                          // 按钮的宽度
 4             height: 23,                         // 按钮的高度
 5             method:"get",
 6             buttonText: "选择文件",
 7             buttonCursor: 'hand',                // 按钮的鼠标图标
 8             //fileObjName: 'Filedata',            // 上传参数名称
 9             // 两个配套使用
10             fileTypeExts: "*.xls;",             // 扩展名
11             fileTypeDesc: "请选择 xls 文件",     // 文件说明
12             queueID:"fileQueue",
13             'auto': false,
14             'swf'        : '/Content/Script/uploadify/uploadify.swf',
15             'uploader'   : '/Report/ConsumptionAndUtilization/upload',
16             'onUploadStart' : function(file) {
17                 var zTree = $.fn.zTree.getZTreeObj("treeDemo");
18                 var checkCount = zTree.getCheckedNodes(true);
19                     var orgid = checkCount[0].OrganizationID;
20                     $("#uploadify").uploadify("settings", "formData", {'date' : $("#textBegindate").val(), 'orgid' : orgid});
21 
22 
23             }
24         });

c#

 1      public ActionResult Upload(HttpPostedFileBase Filedata)
 2         {
 3 
 4 
 5       
 6             // 如果没有上传文件
 7             if (Filedata == null ||
 8                 string.IsNullOrEmpty(Filedata.FileName) ||
 9                 Filedata.ContentLength == 0)
10             {
11                 return this.HttpNotFound();
12             }
13 
14             // 保存到 ~/photos 文件夹中,名称不变
15             //  string filename = System.IO.Path.GetFileName(Filedata.FileName);
16             string filename = Request.QueryString["date"] + "_" + Request.QueryString["orgid"] + ".xls";18             string virtualPath =
19                 string.Format("~/Report/ConsumptionAndUtilization/Monthly/Tables/{0}", filename);
20             // 文件系统不能使用虚拟路径
21             string path = this.Server.MapPath(virtualPath);
22             Filedata.SaveAs(path);           
23          
24 
25               return this.Json(new { });
26         }

 

转载于:https://www.cnblogs.com/zhutiehan/p/5730327.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值