asp.net中上传组件的用法
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
}
{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
else12
{13
Response.Write("<script language='javascript'>alert('你选择的图片格式错误');</script>");14
}15
}



浙公网安备 33010602011771号