protected void Button1_Click(object sender, EventArgs e)
{
string savedir = @"~/Images/";
if (FileUpload1.HasFile)
{
string filename = Server.HtmlEncode(FileUpload1.FileName);
string exetension = System.IO.Path.GetExtension(filename);
if ((exetension == ".jpg") || (exetension == ".gif"))
{
string savepath = savedir + filename;
FileUpload1.SaveAs(Server.MapPath(savepath));
Image1.ImageUrl = savepath.ToString();
Label1.Text = "Image Uploaded and path is: <br/><b>"+
savepath.ToString()+"</b>";
}
else
{
Label1.Text ="Upload Images jpg or gif";
}
}
else
{
Label1.Text ="Please upload files, Upload control is empty";
}
}