asp多文件上传(转)
来源:互联网 发布:linux 挂载移动硬盘 编辑:程序博客网 时间:2024/06/08 03:54
<html xmlns="http://www.w3.org/1999/xhtml" >
<HEAD>
<title>多文件上传 </title>
<script language="JavaScript">
function addFile()
{
var str = ' <br /> <INPUT type="file" size="50" NAME="File">'
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
}
</script>
<link href="../Css/dinwei.css" rel="stylesheet" type="text/css" />
</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>
<asp:Button Runat="server" Text="开始上传" ID="UploadButton"> </asp:Button>
<input onclick="this.form.reset()" type="button" value="重置(ReSet)">
<input type="button" value="增加(Add)" onclick="addFile()">
</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>
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack) this.SaveImages();
}
private Boolean SaveImages()
{
///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files;
YXun.BLL.tv_FileTable fileControl = new YXun.BLL.tv_FileTable();//文件控制类
YXun.Model.tv_FileTable Obj;//文件实体类
/// '状态信息
StringBuilder strMsg = new StringBuilder();
strMsg.Append(" <center> <strong>上传成功! </strong> </center>");
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("../UpLoadFile/") + fileName);
//添加到数据库中把信息
Obj = new YXun.Model.tv_FileTable();
Obj.FileName = fileName.Replace("'", "/'");
Obj.FilePath = "/UpLoadFile/" + fileName.Replace("'", "/'");
Obj.FileRemark = "";
Obj.AddTime = DateTime.Now;
Obj.ID = Guid.NewGuid().ToString();
fileControl.Add(Obj);
}
}
strStatus.Text = strMsg.ToString();
return true;
}
catch (System.Exception Ex)
{
strStatus.Text = Ex.Message;
return false;
}
}
- asp多文件上传(转)
- ASP多文件上传
- asp.net文件上传,多文件上传。
- asp.net 多文件上传
- asp.net 多文件上传
- ASP.NET多文件上传
- Asp.Net多文件上传
- asp.net多文件上传
- asp.net多文件上传
- asp.net多文件上传
- 在ASP.NET中实现多文件上传[转]
- [转]在ASP.NET中实现多文件上传
- asp:小数据无组件上传(支持多文件)
- 一次选择多文件上传 ASP.NET(Flash)
- 在ASP.NET中实现多文件上传(二)
- ASP中多文件同时上传解决方案
- ASP.NET 多文件上传自定义控件
- ASP.NET多文件上传方法
- Lucene:基于Java的全文检索引擎简介
- Js url 编码
- 从google doc转移-直接交换排序
- linux常用命令
- 生成gif 性能优化
- asp多文件上传(转)
- 恢复注册表中的sybase服务信息
- arcgis 新得
- java程序员成长全计划
- 从google doc转移-直接插入排序
- jsp页面多文件上传(转)
- arcgis9.3 desktop的安装
- CS模式短信监控系统的设计与实现
- 包含文件 '../md5.asp' 不能用 '..' 表示父目录,IIS如何启用父目录