asp.net上传控件在UpdatePanel下使用多个会有问题可以通过iframe或者自己写ajax实现
解决方案 »
- 关于reportview 不显示中文的问题
- 如何分行显示textarea中的内容?
- 会员有100多万,用membership开发的会员管理系统性能是否有问题?
- Page.LoadTemplate 和 Page.LoadControl 到底有啥区别,分别用在什么场合比较合适?
- 新手弱问:如何在页面上实现 探出的选择日期效果呢?
- 帮我看看这段简单的代码有什么问题
- SQL Server 不存在或访问被拒绝????
- 当把数据库里的数据导出为xml文件时,怎么做使自己可以选择目录?
- 有关BBS图形界面的问题
- 关于gridview问题
- ASP无组件下载提示http错误:400 Bad Request
- 一个asp.net数据显示问题?大大们帮小弟一把
欢迎加入我们QQ群,大家一块学习QQ群号:2976157
搜一下很多的
http://www.cnblogs.com/cloudgamer/archive/2008/12/31/1314766.html
http://www.cnblogs.com/jembai/articles/1281266.html
要代码留个邮箱
{ 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, file_id;
int year = System.DateTime.Now.Year;
int month = System.DateTime.Now.Month;
int day = System.DateTime.Now.Day;
int hour = System.DateTime.Now.Hour;
int minute = System.DateTime.Now.Minute;
int second = System.DateTime.Now.Second;
int millisecond = System.DateTime.Now.Millisecond;
//string my_file_id = year.ToString() + month.ToString() + day.ToString() + hour.ToString() + minute.ToString() + second.ToString() + millisecond.ToString() + iFile.ToString(); fileName = System.IO.Path.GetFileName(postedFile.FileName);
fileExtension = System.IO.Path.GetExtension(fileName);
file_id = fileName;
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>");
strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
strMsg.Append("上传文件的文件名:" + file_id + "<br>");
strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("upload/") + file_id);
}
}
strStatus.Text = strMsg.ToString();
return true;
}
catch (System.Exception Ex)
{
strStatus.Text = Ex.Message;
return false;
}
} protected void UploadButton_Click(object sender, EventArgs e)
{
Boolean bl = SaveImages();
if (bl)
{
adminDataBase db = new adminDataBase();
int l = db.Log(Session["adminName"].ToString(), "上传文件");
Response.Write("<script>alert('上传成功!')</script>");
}
else
{
Response.Write("<script>alert('上传失败!')</script>");
}
}
这个引用。。<%@ Page Language="C#" AutoEventWireup="true" CodeFile="uploadIT.aspx.cs" Inherits="_uploadIT" %><!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>
<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" OnClick="UploadButton_Click"></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>