protected void Button1_Click(object sender, EventArgs e) { string FullFileName = this.flLl.PostedFile.FileName; string fileName = FullFileName.Substring(FullFileName.LastIndexOf("\\") + 1); this.txtimage.Text = "~/photo/"+ fileName; string type = fileName.Substring(fileName.LastIndexOf(".") + 1); if (type == "bmp" || type == "jpg" || type == "gif") { this.flLl.PostedFile.SaveAs(Server.MapPath("~/photo") + "\\" + fileName); this.imgphoto.ImageUrl = "~/photo/" + fileName; } else { Response.Write("<script lanuage='javaScript'>alert('你上传的格式有误!');location='javascript:history.go(-1)'</script>"); } }