asp.net 多文件上传的代码举例
本文导语: 1,前台页面部分 代码示例: asp.net多文件上传_www. Upload ...
1,前台页面部分
asp.net多文件上传_www.
Upload
function addFiles(oContainer)
{
var sLineHTML="";
oContainer.insertAdjacentHTML('beforeEnd',sLineHTML);
}
function delFileInput(oInputButton)
{
var divToDel=oInputButton.parentNode;
divToDel.parentNode.removeChild(divToDel);
}
多附件上传 作者:Bt之家 cjlwxy
继续添加
2,后台代码部分
using System;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
public const string StatusChangeFilePath = "StatusChangeFile/"; //附件保存地址
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpLoad_Click(object sender, EventArgs e)
{
string sFilesName = "";
HttpPostedFile oPostedFile;
int n = 0;
n = Request.Files.Count;
for (int i = 0; i < n; i++)
{
oPostedFile = Request.Files.Get(i);
sFilesName = UpLoadMoreFile(oPostedFile, StatusChangeFilePath);
lblError.Text = "上传成功";
}
}
private string UpLoadMoreFile(HttpPostedFile Postfile, string Path)
{
string fileName = "";
if (Postfile.FileName == "")
{
return "";
}
else
{
fileName = Postfile.FileName;
fileName = fileName.Substring(fileName.LastIndexOf("//"), fileName.Length - fileName.LastIndexOf("//"));
Postfile.SaveAs(Server.MapPath(Path + fileName));
return "成功";
//Postfile.cu
}
}
}
之前,我们介绍过一篇asp.net 多文件上传的例子,有需要的朋友,也可以参考下。