using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (FileUpload1.HasFile)
            {
                //将图像保存到程序所在的文件夹中
                FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName));
                Session["imagename"] = FileUpload1.FileName;
                Response.Write("<script>alert('恭喜你，已成功上传了图像！')</script>");
                Button2.Enabled = true;
            }
        }
        catch
        {
            Response.Write("<script>alert('对不起，上传图像失败！')</script>");
        }

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Image1.ImageUrl = Session["imagename"].ToString();   //动态显示图像
        Image1.Visible = true;
    }
}
