Click here to Skip to main content
15,902,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using a file upload control to upload images in a upload folder
how i can fix only jpg format to upload

plz help



thanks
Posted

Please go through the solution...
C#
if (FileUpload1.HasFile)
{
    string extension = System.IO.Path.GetExtension(FileUpload1.FileName);

    if (extension == ".jpg")
    {
        FileUpload1.SaveAs("yourpath" + FileUpload1.FileName);

    }
    else
    {
    Response.Write("Only .Jpg allowed");
    }
}
 
Share this answer
 
Comments
neeraj_ 15-Apr-14 3:07am    
response.write not working in asp.net sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900