code for file upload filter upload file

Posted by Mona.Agr1186 under ASP.NET on 4/6/2013 | Points: 10 | Views : 1301 | Status : [Member] | Replies : 1
when user upload file any type then check that file .jpg,.gif .txt etc
if that is not match then upload file is remove




Responses

Posted by: Jayakumars on: 4/6/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

try this Code


protected void bt_Upload_Click(object sender, EventArgs e)
{
if (Fp1.HasFile)
{
string Fup1 = Fp1.PostedFile.FileName;
string fup2 = Path.GetExtension(Fup1);

if (fup2 == ".jpg" || fup2 == ".gif" || fup2 == ".txt")
{
Label2.Text = "Select File Extension is In Correct";
}
else
{
Label2.Text = "Select File Extension is Correct";
}

}
}

Mark as Answer if its helpful to you

Mona.Agr1186, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response