net超炫的多文件上传源码|net实现文件上传到服务器

|

Ⅰ asp.net用多线程上传大文件(500MB~2G)

大文件上传,进度条效果推荐你用uploadify插件结合asp.net来做,这个的实现网上有例子,我这里自己也做了一个,上传页面是uploadify3.2/index.html ,上传处理程序是upload.ashx。用vs2010制作,需要framework4.0环境的支持。 经测试打文件上传功能已经稳定,,进度条显示效果友好。

最近打算把原来的asp网站改成asp.net的,所以做了这个,你可以参考一下。

Ⅱ Asp.net 批量上传附件如何实现 谢谢,

FileUpload实现单图片上传,如果想多图片上传,你试试这个: <tr> <td align="right" valign="top"> 试卷照片: </td> <td align="left"> <div id="_container"> <input id="File1" type="file" name="File" runat="server" size="10" /> </div> </td> <td align="left" valign="bottom"> <input type="button" value="添加" onclick="addFile()" /> </td> </tr>addFile()源码://多文件上传,动态生成多个上传控件function addFile() { var div = document.createElement("div"); var f = document.createElement("input"); f.setAttribute("type", "file"); f.setAttribute("name", "file"); f.setAttribute("size", "10"); div.appendChild(f); document.getElementById("_container").appendChild(div);}后台页面调用: #region 上传添加图片的方法 /// <summary> /// 上传添加图片的方法 /// </summary> /// <param name="nId">关联id</param> private static void UploadAndAddPicTures(int nId) { LMS.BLL.TRAIN_Pictrue PictrueBLL = new LMS.BLL.TRAIN_Pictrue(); List<LMS.Model.TRAIN_Pictrue> list = new List<LMS.Model.TRAIN_Pictrue>(); //遍历File表单元素 HttpFileCollection files = HttpContext.Current.Request.Files; for (int iFile = 0; iFile < files.Count; iFile++) { //检查文件扩展名字 HttpPostedFile postedFile = files[iFile]; string fileName; fileName = System.IO.Path.GetFileName(postedFile.FileName); if (fileName.ToLower() != "") { LMS.Model.TRAIN_Pictrue Pictrue = new LMS.Model.TRAIN_Pictrue(); string scurTypeName = fileName.Substring(fileName.LastIndexOf(".")); //初始化原图物理路径 string sGuid_phy = Guid.NewGuid().ToString(); string sUrl_phy = ConfigurationManager.AppSettings["PhysicsObjectPath"].ToString() + sGuid_phy + scurTypeName; //初始化缩略图物理路径 string sGuid_web = Guid.NewGuid().ToString(); string sUrl_web = ConfigurationManager.AppSettings["PhysicsObjectPath"].ToString() + sGuid_web + scurTypeName; postedFile.SaveAs(sUrl_phy);//保存原图 PTImage.ZoomAuto(postedFile, sUrl_web, 100, 100, "", "");//生成缩略图,并保存 //保存原图虚拟路径到数据库 Pictrue.path = ConfigurationManager.AppSettings["WebObjectPath"].ToString() + sGuid_phy + scurTypeName; //保存缩略图虚拟路径到数据库 Pictrue.shrinkpath = ConfigurationManager.AppSettings["WebObjectPath"].ToString() + sGuid_web + scurTypeName; Pictrue.parid = nId; Pictrue.tables = "TRAIN_Hotel_MonthExam"; list.Add(Pictrue); } } PictrueBLL.Add(list); } #endregion希望对你有帮助!

Ⅲ asp.net 一般处理程序(ashx)如何多次接收上传文件(多文件批量上传)

Likethis:比如源前台有3个INPUT:然后后台:HttpFileCollectionfiles=HttpContext.Current.Request.Files;//这个files里面就是你上传文件的集合。遍历即可。

Ⅳ .net实现文件上传到服务器

1、前端界面十分简单,只是放一个file类型的和一个按钮,并且为这个按钮添加点击事件(btnUpLoad_Click),如下图:

protectedvoidbtnUpLoad_Click(objectsender,EventArgse){//取出所选文件的本地路径stringfullFileName=this.UpLoad.PostedFile.FileName;//从路径中截取出文件名stringfileName=fullFileName.Substring(fullFileName.LastIndexOf()+1);//限定上传文件的格式stringtype=fullFileName.Substring(fullFileName.LastIndexOf(.)+1);if(type==doc||type==docx||type==xls||type==xlsx||type==ppt||type==pptx||type==pdf||type==jpg||type==bmp||type==gif||type==png||type==txt||type==zip||type==rar){//将文件保存在服务器中根目录下的files文件夹中stringsaveFileName=Server.MapPath(/files)++fileName;UpLoad.PostedFile.SaveAs(saveFileName);Page.ClientScript.RegisterStartupScript(Page.GetType(),message,<scriptlanguage='javascript'defer>alert('文件上传成功!');</script>);//向数据库中存储相应通知的附件的目录BLL.news.InsertAnnexBLLinsertAnnex=newBLL.news.InsertAnnexBLL();AnnexEntityannex=newAnnexEntity();//创建附件的实体annex.AnnexName=fileName;//附件名annex.AnnexContent=saveFileName;//附件的存储路径annex.NoticeId=noticeId;//附件所属“通知”的ID在这里为已知insertAnnex.InsertAnnex(annex);//将实体存入数据库(其实就是讲实体的这些属性insert到数据库中的过程,具体BLL层和DAL层的代码这里不再多说)}else{Page.ClientScript.RegisterStartupScript(Page.GetType(),message,<scriptlanguage='javascript'defer>alert('请选择正确的格式');</script>);}}

Ⅳ 求C#.NET 以上超大文件上传和断点续传服务器的实现

我以前写过来这样的例子,用自的Socket TCP协议,多大文件都可以,只是时间问题,主要是断点续传,传输文件时,客户端请求一下服务器端,服务器端返回当前文件的已经接收的字节大小,客户端收到服务器端已经接收的字节大小时,就通过指针移动你要传输的文件字节位置为接收的字节大小的位置,继续通过Socket传输,无论是Http还是什么原理差不多

Ⅵ ASP.NET中怎么实现多文件同时上传要求点浏览的时候可以一次性多选文件

多放几个fileupload后台用Request.Files获取,这是你上传文件的集合。


赞 (0)