uploadifive上传文件

uploadifive是一个款基于H5的上传文件的插件。优点是,可以在PC端,也可以在手机上进行操作。缺点是,IE9以下的兼容性不好。

View:

 1 <!DOCTYPE html>
 2 
 3 <html>
 4 <head>
 5     <meta name="viewport" content="width=device-width" />
 6     <title>Index</title>
 7     <script src="~/Scripts/jquery-1.10.2.min.js"></script>
 8     <script src="~/Content/uploadifive/jquery.uploadifive.min.js"></script>
 9     <link href="~/Content/uploadifive/uploadifive.css" rel="stylesheet" />
10 </head>
11 <body>
12     <div id="queue"></div>
13     <input type="file" id="file_upload" name="file_upload" />
14 
15     <script>
16         $(function () {
17             $('#file_upload').uploadifive({
18                 'auto': true,
19                 'queueID': 'queue',
20                 'buttonText': '上传文件',
21                 'uploadScript': '/File/UploadFile',
22                 'onUploadComplete': function (file, data) {
23                     if (data) {
24                         alert('上传成功')
25                     } else {
26                         alert('上传失败' + rspdesc);
27                     }
28                 }
29             });
30         });
31     </script>
32 </body>
33 </html>

Controller

 1  /// <summary>
 2  /// 上传文件
 3  /// </summary>
 4  public ActionResult UploadFile(HttpPostedFileBase fileData)
 5  {
 6      if (fileData.ContentLength > 0)
 7      {
 8          string fileExt = Path.GetExtension(fileData.FileName);
 9          string fileName = DateTime.Now.ToString("yyyyMMdd_HHmmssff") + fileExt;
10          string savePath = Server.MapPath("~/Upload/"+ fileName);
11          fileData.SaveAs(savePath);
12          return Content("ok");
13      }
14      else
15      {
16          return null;
17      }
18  }

 

转载于:https://www.cnblogs.com/sunice/p/6380161.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值