protected void btnUpload_Click(object sender, EventArgs e)
{
if (upload1.HasFile)
{
HttpPostedFile file
= upload1.PostedFile;
string extension = Path.GetExtension(file.FileName);
string fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + extension;
string path = Server.MapPath("uploads");
string savePath = Path.Combine(path, fileName);
//Response.Write(savePath);
string imagePath = "uploads/" + fileName;
file.SaveAs(savePath);
if (extension.Equals(".bmp") || extension.Equals(".jpg") || extension.Equals(".gif"))
{
Image1.ImageUrl
= imagePath;
}
}
}

1.重新命名成yyyyMMddhhmmss+后缀名的文件就行了。
2.Guid
3.yyyyMMddhhmmss+原文件名

相关文章:

  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-01-21
  • 2021-12-21
  • 2022-12-23
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-11-16
  • 2021-09-22
  • 2022-12-23
相关资源
相似解决方案