using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
bool fileOK = false;
string path = Server.MapPath("~/Temp/");
if (this.FileUpload1.HasFile)
{
string fileException = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
string[] allowedException ={ ".gif", ".bmp", ".png", ".jpg" };
for (int i = 0; i < allowedException.Length; i++)
{
if (fileException == allowedException[i])
{
fileOK = true;
}
}
}
if (fileOK)
{
try
{
this.FileUpload1.SaveAs(path + FileUpload1.FileName);
}
catch (Exception ee)
{
}
}
else
{
}
}
}