1
{
2
string fullFileName=this.File1.PostedFile.FileName;//获得文件全路径
3
string fileName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);//获取文件名
4
string type=fullFileName.Substring (fullFileName.LastIndexOf(".")+1); //取得文件后缀名
5
if(type=="jpg"||type=="gif"||type=="bmp")
6
{
7
this.File1.PostedFile.SaveAs(Server.MapPath("up")+"\\"+fileName);
8
this.Image1.Visible=true;
9
this.Image1.ImageUrl="up/"+fileName;
10
}
11
else
12
{
13
Response.Write("<script language='javascript'>alert('你选择的图片格式错误');</script>");
14
}
15
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](/Images/OutliningIndicators/InBlock.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
15
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)