PlutoFDZ
PlutoFDZ
2015-09-22 11:26

使上传的图片显示它原有的格式

  • 图片
  • asp.net

if (FileUpload1.HasFile)
{
string strType=FileUpload1.PostedFile.ContentType;
if (strType == "image/bmp" || strType == "image/jpeg" || strType == "image/png" || strType == "image/gif")
{
string strFileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
FileUpload1.SaveAs(Server.MapPath("images/" + strFileName + strType.ToString()));
Image1.ImageUrl = "images/" + strFileName + strType.ToString();
Response.Write("上传成功!");
}
else
{
Response.Write("文件类型不正确!");
}
}
else
{
Response.Write("请选择文件");
}

            应该怎样去改,求解
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答