Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Filter upload file

Author  Topic 

seyha_moth
Yak Posting Veteran

74 Posts

Posted - 2007-03-12 : 09:03:23
Dear sir or madam

I have a problem related to uploading file in asp.net.I want to use file upload control that I can filter some extensions.

How should I do?
Thank you in advance!

Good Luck!

seyha moth

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-12 : 09:12:00
Just check the extension when the file is uploaded. All the info you need is there in the HtmlInputControl. (note: this is .net 1.1, 2.0 may have changes)

The PostedFile property of your control contains all the info about the file you need. You can check the filename and parse it out to check the extension (i.e., if inp.PostedFile.FileName.EndsWith(".jpg") ...) or you can examine the ContentType property of the posted file (i.e., If inp.PostedFile.ContentType = "image/jpeg" .... ), and so on. You can check the ContentLength (i.e., # of bytes in the file) as well.



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -