getting type of a file which is uploading in application.

Posted by Naveen under ASP.NET on 7/2/2008 | Views : 1498 | Status : [Member] | Replies : 1
How to fix uploading for a particular type of files?
e.g., just for text or for images.......???


Posted by: SheoNarayan on: 7/2/2008 [Administrator] HonoraryPlatinum

Here is the code to get the name of the file from FileUpload control and getting the extension name of the file. Once you have the extension name of the file you can validate this for your desired file type.

string postedFile = fileupload1.PostedFile.FileName;

postedFile = System.IO.Path.GetExtension(postedFile);

For further help of limiting the file upload size you may refer to following article.


Sheo Narayan

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

Login to post response