,需要首先建立一个存放照片的文件夹Up
string fullFileName=this.File1 .PostedFile .FileName ;
string fileName=fullFileName.Substring (fullFileName.LastIndexOf ("\\")+1);
string type=fullFileName.Substring (fullFileName.LastIndexOf (".")+1);
if(type=="jpg"||type=="bmp"||type=="gif")
{
this.File1 .PostedFile .SaveAs (Server.MapPath ("up")+"\\"+fileName);
this.izhaopian.ImageUrl ="up/"+fileName;
}
else
{
Response.Write ("<script language='javascript'>alert('你选择的图片格式错误!');</script>");
}