单个文件

.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);

   }

相关文章:

  • 2022-01-10
  • 2022-02-24
  • 2022-12-23
  • 2022-01-05
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-12-05
  • 2021-11-06
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案