------------------------------上传文件------------------------------------------
string fullFileName=this.Filel.PostedFile.FileName;
string fullName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
this.Filel.PostedFile.SaveAs(Server.MapPath("up")+"\\"+fileName);
------------------------------判断是否是图片------------------------------------------
string fullFileName=this.Filel.PostedFile.FileName;
string fullName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
string type=fullFileName.Substring(fullFileName.LastIndexOf(".")+1);
if(type=="jpg"||type=="bmp"||type=="gif")
{
this.Filel.PostedFile.SaveAs(Server.MapPath("up")+"\\"+fileName);
}
else
{
Response.Write("<script language='javascript'>alert('你选择的图片格式错误!');</script>");
}
------------------------------将图片在页面上进行显示------------------------------------------
string fullFileName=this.Filel.PostedFile.FileName;
string fullName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
string type=fullFileName.Substring(fullFileName.LastIndexOf(".")+1);
if(type=="jpg"||type=="bmp"||type=="gif")
{
this.Filel.PostedFile.SaveAs(Server.MapPath("up")+"\\"+fileName);
this.Image1.ImageUrl="up/"+fileName;
}
else
{
Response.Write("<script language='javascript'>alert('你选择的图片格式错误!');</script>");
}
作者:吴旭晓 | 来源:个人博客 | 点击量:2128 | 发布时间:2010-09-08
最新留言 |
返回上一页 |
返回首页