多文件上传
来源:互联网 发布:隔壁老王淘宝 编辑:程序博客网 时间:2024/06/05 14:56
多文件上传
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="" Width="125px">
<asp:FileUpload ID="fu" runat="server" />
</asp:Panel>
<asp:TextBox ID="tb_Sum" runat="server"></asp:TextBox>
<asp:Button ID="btn_Add" runat="server" Text="增加" OnClick="btn_Add_Click" />
<asp:Button ID="btn_Upload" runat="server" Text="上传全部" OnClick="btn_Upload_Click" /></div>
</form>
</body>
后台代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Add_Click(object sender, EventArgs e)
{
FileUpload fu;
for (int i = 0; i < Convert.ToInt32(tb_Sum.Text); i++)
{
fu = new FileUpload();
fu.ID = "fu_" + i.ToString();
Panel1.Controls.Add(fu);
}
}
protected void btn_Upload_Click(object sender, EventArgs e)
{
string f_Name, f_Size, f_Type;
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
f_Name = Path.GetFileName(hpf.FileName);
f_Size = hpf.ContentLength.ToString();
f_Type = hpf.ContentType;
hpf.SaveAs(Server.MapPath("../up/") + f_Name);
Response.Write(f_Name + "<br>" + f_Size + "<br>" + f_Type + "<br>");
}
}
}
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="" Width="125px">
<asp:FileUpload ID="fu" runat="server" />
</asp:Panel>
<asp:TextBox ID="tb_Sum" runat="server"></asp:TextBox>
<asp:Button ID="btn_Add" runat="server" Text="增加" OnClick="btn_Add_Click" />
<asp:Button ID="btn_Upload" runat="server" Text="上传全部" OnClick="btn_Upload_Click" /></div>
</form>
</body>
后台代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Add_Click(object sender, EventArgs e)
{
FileUpload fu;
for (int i = 0; i < Convert.ToInt32(tb_Sum.Text); i++)
{
fu = new FileUpload();
fu.ID = "fu_" + i.ToString();
Panel1.Controls.Add(fu);
}
}
protected void btn_Upload_Click(object sender, EventArgs e)
{
string f_Name, f_Size, f_Type;
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
f_Name = Path.GetFileName(hpf.FileName);
f_Size = hpf.ContentLength.ToString();
f_Type = hpf.ContentType;
hpf.SaveAs(Server.MapPath("../up/") + f_Name);
Response.Write(f_Name + "<br>" + f_Size + "<br>" + f_Type + "<br>");
}
}
}
- 文件上传(多文件)
- asp.net文件上传,多文件上传。
- 单文件上传、多文件上传
- struts2文件上传与多文件上传
- 单文件上传和多文件上传
- PHP文件上传功能 -- 多文件上传
- struts2文件上传(多文件上传)
- SpringMVC文件上传 多文件上传实例
- Struts2之文件上传,多文件上传
- SpringMVC文件上传 多文件上传实例
- 文件上传及多文件上传
- Spring boot 文件上传(多文件上传)
- Struts文件上传--2.多文件上传
- spring boot文件上传【多文件上传】
- FastDFS上传文件二 : 多文件上传
- 多文件上传
- 单/多文件上传
- 多个文件上传
- 赢在中国》第三赛季36进12现场演讲
- GridView 常用操作技巧
- mysql 表修复
- 上传图片生成略缩图“最佳解决”
- FairStars Recorder 分析
- 多文件上传
- POJ1002
- 动态sql语句基本语法
- 2007年软件企业百强
- 项目所遇到的一些管理问题解决方法
- POJ1003
- 好生意一年历程(8/10)
- 马云送给正在奋斗的人的经典语句
- WIN7 VS2005+sp1 无法调试代码了!