I'm using the HtmlInputFile control to upload a image file. I only want to allow the user to upload jpg or jpeg extensions. How do I do limit them to those type of files?
You can get the fully qualified filename (eg. "C:/test.txt" of the uploaded file using
HtmlInputFile1.PostedFile.FileName
A bit of string manipulation will get you the extension easy enough. However, you can get the content type (eg. "image/jpeg" using
HtmlInputFile1.PostedFile.ContentType
This will let you kno the type of the file being uploaded not just extension. That way even if the file has the wrong extension but is a jpg you can still use it or if it is right extension but not really jpg you will spot that as well.
Hope this helps
Rob
Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.