码迷,mamicode.com
首页 > 其他好文 > 详细

uploadify使用教程

时间:2016-08-02 20:34:51      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

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         }

 

uploadify使用教程

标签:

原文地址:http://www.cnblogs.com/zhutiehan/p/5730327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!