码迷,mamicode.com
首页 > Web开发 > 详细

input file实现批量上传

时间:2016-10-28 09:48:09      阅读:760      评论:0      收藏:0      [点我收藏+]

标签:cursor   form   date   bsp   path   pos   post   request   upload   

1、需求实现word批量上传。

2、使用插件jquery-form.js

3、html代码

注意 multiple="multiple"

 

1 <form id="frm_upload" method="post" enctype="multipart/form-data">
2   <input type="file" id="filepath" multiple="multiple" name="file" style="width: 60px; cursor: pointer" accept="application/msword" />
3 </form>

4、js代码

1  $("#frm_upload").ajaxSubmit({
2   url: "Public/UploadAttachZD",
3   type: "post",
4   success: function (ort) {
5    }
6 });

5、后台代码

 1 string uploadroot = Server.MapPath("~/upload") + "\\11";
 2 if (!Directory.Exists(uploadroot))
 3   Directory.CreateDirectory(uploadroot);
 4 var files = Request.Files;
 5 if (files.Count != 0)
 6 {
 7   for (int i = 0; i < files.Count; i++)
 8   {
 9     var pf = files[i];
10     int npos = pf.FileName.LastIndexOf(.);
11     string fileext = "";
12     if (npos != -1)
13     {
14       fileext = pf.FileName.Substring(npos + 1);
15     }
16     string newfilepath = DateTime.Now.Ticks.ToString().ToLower() + "." + fileext;
17     pf.SaveAs(uploadroot + "\\" + newfilepath);
18   }
19 }

 

  

input file实现批量上传

标签:cursor   form   date   bsp   path   pos   post   request   upload   

原文地址:http://www.cnblogs.com/Lv2014/p/6006412.html

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