ASP.NET中怎么实现多文件同时上传?要求点浏览的时候可以一次性多选文件
1个回答
2013-04-01
展开全部
upload.aspx
<%@ 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>
upload.aspx.cs
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();
}
<%@ 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>
upload.aspx.cs
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();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询