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;
            }
        }
    }

相关文章:

  • 2021-12-20
  • 2021-08-02
  • 2022-12-23
  • 2021-04-27
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
相关资源
相似解决方案