//根据时间生成图片名
string SaveName=DateTime.Now.ToString("yyyyMMddhhmmssfff");
string fn=myFile.PostedFile.FileName;
strImageName=SaveName+fn.Substring(fn.LastIndexOf("."));//图片名加上图片后缀名
string strpath=Server.MapPath("")+"\\UpImages\\"+strImageName;//得到将要保存图片的路径
myFile.PostedFile.SaveAs(strpath);//把图片保存在此路径中
bool result=DUI.Insert_UpImage(strImageName,Publishtime);//此为保存图片到数据库中的方法
if(result)
{
Response.Write("<script>alert('图片录入成功')</script>");
Response.Write("<script>location.href=location.href</script>");
}
}
else
{
Response.Write("<script>alert('请选择正确的图片文件')</script>");
return;
}
}
}