<%@ Page language="c#" Codebehind="UpLoad.aspx.cs" AutoEventWireup="false" Inherits="WebPortal.Upload" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>多文件上传</title> <script language="JavaScript"> function addFile() { var str = '<INPUT type="file" size="50" NAME="File">' document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str) } </script> </HEAD> <body> <form id="form1" method="post" runat="server" enctype="multipart/form-data"> <div align="center"> <h3>多文件上传</h3> <P id="MyFile"><INPUT type="file" size="50" NAME="File"></P> <P> <input type="button" value="增加(Add)" onclick="addFile()"> <input onclick="this.form.reset()" type="button" value="重置(ReSet)"> <asp:Button Runat="server" Text="开始上传" ID="UploadButton"></asp:Button> </P> <P> <asp:Label id="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px" BorderStyle="None" BorderColor="White"></asp:Label> </P> </div> </form> </body> </HTML>
pay attention to the following code and give a thinking.
<%@ Page language="c#" Codebehind="WebForm7.aspx.cs" AutoEventWireup="false" Inherits="WebTestApplication1.WebForm7" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>多文件上传</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <script language="JavaScript"> function addFile() { var str = '<div><INPUT type="file" size="50" NAME="File"></div>' document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str) } function ff()//give a thinking! { document.getElementById('MyFile').style.display='none'; } </script> </HEAD> <body> <form id="form1" method="post" runat="server" enctype="multipart/form-data"> <div align="center"> <h3>多文件上传</h3> <div id="MyFile"><INPUT type="file" id="aa" size="50" NAME="File" onfilterchange="addFile()" onreadystatechange="addFile()" onpropertychange="addFile() ;"></div> <P> <input type="button" value="增加(Add)" onclick="ff()" > <input onclick="this.form.reset()" type="button" value="重置(ReSet)"> <asp:Button Runat="server" Text="开始上传" ID="UploadButton"></asp:Button> </P> <P> <asp:Label id="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px" BorderStyle="None" BorderColor="White"></asp:Label> </P> </div> </form> </body> </HTML>
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace WebPortal { /// <summary> /// UpLoad 的摘要说明。 /// 实现多文件上传 /// </summary> public class Upload : System.Web.UI.Page { protected System.Web.UI.WebControls.Button UploadButton; protected System.Web.UI.WebControls.Label strStatus; private void Page_Load(object sender, System.EventArgs e) { /// 在此处放置用户代码以初始化页面 if (this.IsPostBack) this.SaveImages(); } private Boolean SaveImages() { ///'遍历File表单元素 HttpFileCollection files = HttpContext.Current.Request.Files; /// '状态信息 System.Text.StringBuilder strMsg = new System.Text.StringBuilder(); strMsg.Append("上传的文件分别是:<hr color=red>"); try { for(int iFile = 0; iFile < files.Count; iFile++) { ///'检查文件扩展名字 HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension; fileName = System.IO.Path.GetFileName(postedFile.FileName); if (fileName != "") { fileExtension = System.IO.Path.GetExtension(fileName); strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>"); strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>"); strMsg.Append("上传文件的文件名:" + fileName + "<br>"); strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>"); ///'可根据扩展名字的不同保存到不同的文件夹 ///注意:可能要修改你的文件夹的匿名写入权限。 postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("images/") + fileName); } } strStatus.Text = strMsg.ToString(); return true; } catch(System.Exception Ex) { strStatus.Text = Ex.Message; return false; } } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.ID = "Upload"; this.Load += new System.EventHandler(this.Page_Load); } #endregion } }
发表评论
-
转载:jquery webservice 跨域
2013-01-28 16:06 1261现在的JQuery中$.ajax方法支持跨域读取json数 ... -
excel 导入导出
2011-10-27 10:32 848excel 导入导出 -
仿google 日历
2011-08-24 23:10 872仿google 日历仿google 日历仿google 日历仿 ... -
DataTime.ToString("xx")
2011-08-12 13:57 1158//2008年4月24日 System.DateTi ... -
ASP.Net 文件上传大小限制IIS7
2011-08-11 09:41 2662ASP.Net 文件上传大小限制解决方案修改IIS7/ ... -
Request
2011-07-12 17:08 937Request.params、Request、Request. ... -
ASP.NET MVC 第五回 ActionResult的其它返回值
2011-06-21 15:38 1805ASP.NET MVC 第五回 ActionResult的 ... -
dbhelper table扩展
2011-06-15 11:00 699dbhelper table扩展 -
C#扩展对象的方法,this关键字
2011-06-15 10:58 1211namespace ConsoleApplication2 ... -
asp.net mvc2.0的Areas多级文件夹问题
2011-06-15 10:53 1323此文只写给遇到同样问题的人看的,因此写得会有点短 ... -
WCF实例(基于TCP协议的配置)
2011-01-10 17:52 1092WCF实例(基于TCP协议的配置) 启动ServerHost ... -
反射机制
2010-06-24 09:39 834反射的定义:审查元 ... -
委托线程
2010-06-24 09:37 774本系列教程主要包括如下内容:1. BeginInvoke ... -
读写图片
2008-11-12 17:33 893<%@ Import Namespace="S ... -
asp.net 自定义web控件
2008-11-11 15:34 840<%@ Register TagPrefix=&quo ... -
PDF-activereport
2008-09-11 13:36 1449using System; using System.Coll ... -
xml read -write -update -remove
2008-08-19 14:05 997<?xml version="1.0" ... -
read file directory
2008-08-13 09:31 779using System; using System.Coll ... -
web。config
2008-06-27 10:41 770一、认识Web.config文件 网管下载dl.bitscn. ... -
Application,Session,Cookie,ViewState,Cache
2008-06-26 18:20 1598Application 1. Applicat ...
相关推荐
用Ext编写的多文件上传组件,已封装。 支持多文件上传,文件下载,文件删除,
java多文件上传实现,上传界面采用flash,同时显示上传进度条
ajaxfileupload.js 这是个非常好的异步上传图片的插件,来解决form表单上传时要刷新页面的问题。支持多文件上传
使用普通表单的input框,引入多文件上传插件,传报文格式的参数,表单内容同时提交
bootstrap-fileinput-master多文件上传,多文件预览,网页的代码地址为https://mp.csdn.net/postedit/84098479
说明:支持多文件上传的上传类 使用方法: include '../UploadFile.class.php'; $upload=new UploadFile(); if(!$upload->upload()) { // 上传错误提示错误信息 $this->error($upload->getErrorMsg()); }else{ ...
文件上传比较多,多文件上传少一点 文件下载很少的,看似简单,实则不然 网上的Struts2进行的文件下载一般都是单文件或者固定的文件,并没有(很少)实现随意文件的下载的例子 提供多文件上传,上传成功后,提供...
C#多服务器多文件上传实例,并发,集群对考虑在内
利用flash上传工具,结合jsp来进行多文件上传demo。 能一次性的选择多个文件,有上传进度显示;java项目
.net MVC 实现多文件上传,显示上传进度条,可传多个文件
html5和js多文件上传插件。可任意多文件选择上传,每个文件都可以显示进度,同时可以显示整体进度。采用了html的file对象和blob对象的属性和方法。
C# .NET FileUpload 多文件上传例子,两个方法和思路,适合初学者学习。
完全可运行的Ext多文件上传,带上传速率、进度条等
dhtmlxVault多文件上传dhtmlxVault多文件上传dhtmlxVault多文件上传
swfupload多文件上传带进度条实例,vs2012开发,net4.0框架,可上传多个文件,上传类型、上传大小、上传数量可控,已测试成功!
COS框架实现上传,稍加修改即可实现多文件上传,希望各位采纳
C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载C# 多文件上传下载
uploadify多文件上传例子代码,jsp+servlet实现
SpringMVC单文件上传、多文件上传、文件列表显示、文件下载,具体效果和过程看博文http://blog.csdn.net/evankaka/article/details/45826697