getting type of a file which is uploading in ASP.net application.

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




Responses

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

Up
0
Down
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.

http://dotnetfunda.com/articles/article87.aspx

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

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

Login to post response