简单上传程序,还请高手指点
private void btnUpload_Click(object sender, System.EventArgs e)
{
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"||type=="zip")
{
this.File1.PostedFile .SaveAs (Server.MapPath ("up")+"
\\"+fileName);
//this.Image1 .ImageUrl ="up/"+fileName;
}
else
{
Response.Write ("<script language='javascript'>alert('你选择的文件格式错误!');</script>");
}
}