asp.net单个文件上传和多个文件上传
单个文件
.aspx
<input type="file" />
.cs
string sPath = Server.MapPath("~") + @"\upload\file\;
string FileName = "filename.txt";
UploadFile.PostedFile.SaveAs(sPath + FileName);
多个文件
.aspx
<input type="file" />
<input type="file" />
.cs
HttpFileCollection files = Request.Files;
string sPath = Server.MapPath("~") + @"\upload\file\;
string FileName = string.Empty;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
string Sheet = "file" + System.DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace(" ", "") + "-" + i.ToString();
FileName = Sheet + ".xls";
file.SaveAs(sPath + FileName);
}