求多附件上传代码 如题目,能实现一次选择多个附件的在网上搜一下,都是得一个个附件单独增加的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 html里面没有多附件上传的控件. 如果需要选择多附件,可以用flash上传. qq空间相册就是用flash多文件选择上传的. 不会啊。http://topic.csdn.net/u/20100928/17/7c1e409c-6219-4b13-81e1-8ff1e0534ac2.html看看这个贴子,发的上传,都可以多文件上传的 可以多文件上传啊 下面是例子:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="duo_upfile_Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>多文件上传测试</title> <script type="text/javascript"> function addFile() { var div = document.createElement("div"); var f = document.createElement("input"); f.setAttribute("type", "file") f.setAttribute("name", "File") f.setAttribute("size", "30") div.appendChild(f) var d = document.createElement("input"); d.setAttribute("type", "button") d.setAttribute("onclick", "deteFile(this)"); d.setAttribute("value", "移除") div.appendChild(d) document.getElementById("_container").appendChild(div); } function deteFile(o) { while (o.tagName != "DIV") o = o.parentNode; o.parentNode.removeChild(o); } </script></head><body><form id="form1" runat="server" method="post" enctype="multipart/form-data"><div><table cellpadding="0" cellspacing="0" border="0" runat="server"><tr><td>今天是:<script language="javascript" type="text/javascript"> today=new Date(); function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i] } var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("<font color=#000000 style='font-size:9pt;font-family: 宋体'> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日"," ",d[today.getDay()+1]," ","</font>" );</script><script language="Javascript" type="text/javascript">function MakeArrayday(size) {this.length = size;for(var i = 1; i <= size; i++) {this[i] = "";}return this;}function MakeArraymonth(size) {this.length = size;for(var i = 1; i <= size; i++) {this[i] = "";}return this;}function funClock() {if (!document.layers && !document.all)return;var runTime = new Date();var hours = runTime.getHours();var minutes = runTime.getMinutes();var seconds = runTime.getSeconds();var dn = "";if (hours >= 12) {dn = "";}if (hours == 0) {hours = 12;}if (minutes <= 9) {minutes = "0" + minutes;}if (seconds <= 9) {seconds = "0" + seconds;}movingtime = "<font color=#000000><b>"+ hours + ":" + minutes + ":" + seconds + " " + dn + "</b></font>";if (document.layers) {document.layers.C_clock.document.write(movingtime);document.layers.C_clock.document.close();}else if (document.all) {C_clock.innerHTML = movingtime;}setTimeout("funClock()", 1000)}window.onload = funClock;</script><span class="C_Clock" id="C_clock" style="POSITION: relative" /></td></tr></table></div> <hr style="border-style:inset"/> <h5>多文件上传</h5> <asp:TextBox ID="TextBox2" runat="server" BorderStyle="Inset"></asp:TextBox> <hr style="border-style:inset"/> 用户名:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <br /> <div id="_container"> <input type="file" size="30" name="File" /> <input type="button" value="增加" onclick="addFile()" /> </div> <div> <br /> <asp:Button runat="server" Text="开始上传" ID="UploadButton" onclick="UploadButton_Click"></asp:Button></div> <div style="padding:10px 0"> </div> <div> <asp:Label ID="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px" BorderStyle="None" BorderColor="White"> </asp:Label> </div> </form></body></html>*********************************************************************************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;public partial class duo_upfile_Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void UploadButton_Click(object sender, EventArgs e) { ///'遍历File表单元素 HttpFileCollection files = HttpContext.Current.Request.Files; /// '状态信息 System.Text.StringBuilder strMsg = new System.Text.StringBuilder("您输入的用户名是:" + TextBox1.Text + "<br/><br/><br/>"); 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(); } catch (System.Exception Ex) { strStatus.Text = Ex.Message; } }} 一次选择多个的方法目前有2个:1,采用 Firefox3.6之后的版本,可以支持多选2,自己写插件 http://www.xueit.com/asp.net/show-5162-2.aspx http://www.cnblogs.com/chenping-987123/archive/2010/09/25/1834372.htmljquery上传文件的 http://www.msaspx.com/?dotnet/thread-730-1-1 间隔读取数据库记录,如何解决?? 求助,asp.net 多个页面传递Session后,值丢失 Asp.net中的AccessDataSource如何执行insert 操作? 请教大家:我刚进入到一家网络公司(在之前也没有网络开发的经验),在头一年的时间里,该如何学习web编程呢? 这个代码的构造函数是什么? 关于javascript动态增加行设置列宽的问题 数据库插入问题 菜鸟问题 :数据库数据调用问题 添加的图元显示不出来 奇怪的数据库超时问题 如何设置调试多个断点 后台怎么获取动态创建的CheckBoxList控件的value值?
http://topic.csdn.net/u/20100928/17/7c1e409c-6219-4b13-81e1-8ff1e0534ac2.html
看看这个贴子,发的上传,都可以多文件上传的
<head runat="server">
<title>多文件上传测试</title>
<script type="text/javascript">
function addFile() {
var div = document.createElement("div");
var f = document.createElement("input");
f.setAttribute("type", "file")
f.setAttribute("name", "File")
f.setAttribute("size", "30")
div.appendChild(f)
var d = document.createElement("input");
d.setAttribute("type", "button")
d.setAttribute("onclick", "deteFile(this)");
d.setAttribute("value", "移除")
div.appendChild(d)
document.getElementById("_container").appendChild(div);
} function deteFile(o) {
while (o.tagName != "DIV") o = o.parentNode;
o.parentNode.removeChild(o);
}
</script></head>
<body>
<form id="form1" runat="server" method="post" enctype="multipart/form-data">
<div>
<table cellpadding="0" cellspacing="0" border="0" runat="server">
<tr><td>
今天是:<script language="javascript" type="text/javascript">
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write("<font color=#000000 style='font-size:9pt;font-family: 宋体'> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日"," ",d[today.getDay()+1]," ","</font>" );
</script>
<script language="Javascript" type="text/javascript">
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
if (!document.layers && !document.all)
return;
var runTime = new Date();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var dn = "";
if (hours >= 12) {
dn = "";
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = "<font color=#000000><b>"+ hours + ":" + minutes + ":" + seconds + " " + dn + "</b></font>";
if (document.layers) {
document.layers.C_clock.document.write(movingtime);
document.layers.C_clock.document.close();
}
else if (document.all) {
C_clock.innerHTML = movingtime;
}
setTimeout("funClock()", 1000)
}
window.onload = funClock;</script>
<span class="C_Clock" id="C_clock" style="POSITION: relative" />
</td>
</tr>
</table>
</div>
<hr style="border-style:inset"/>
<h5>多文件上传</h5> <asp:TextBox ID="TextBox2" runat="server" BorderStyle="Inset"></asp:TextBox>
<hr style="border-style:inset"/>
用户名:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<br />
<div id="_container">
<input type="file" size="30" name="File" />
<input type="button" value="增加" onclick="addFile()" />
</div>
<div>
<br />
<asp:Button runat="server" Text="开始上传" ID="UploadButton" onclick="UploadButton_Click"></asp:Button></div>
<div style="padding:10px 0">
</div>
<div>
<asp:Label ID="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px" BorderStyle="None" BorderColor="White">
</asp:Label>
</div>
</form>
</body>
</html>
*********************************************************************************
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;public partial class duo_upfile_Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void UploadButton_Click(object sender, EventArgs e)
{
///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files; /// '状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder("您输入的用户名是:" + TextBox1.Text + "<br/><br/><br/>");
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();
}
catch (System.Exception Ex)
{
strStatus.Text = Ex.Message;
} }
}
1,采用 Firefox3.6之后的版本,可以支持多选
2,自己写插件
jquery上传文件的