HtmlInputFile Probblem

W

Wayne Wengert

I want to restrict the file types that the user can select to "*.jpg". From
what I read in MSDN there is a property (accept="image/*") that should allow
only image type files and then my code would need to check for the jpg type.
When I try to add (accept="image/*") to the <input type="file"...> the VSNET
IDE flags it as an invalid selection?

How should I resolve this?

Wayne
 
P

paulanthony

Add a RegularExpressionValidator to the page.
Set 'controltovalidate' to the id of the file-input control.
Set 'validationexpression' to something like:

"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.bmp|.BMP||.gif|.GIF|.jpg|.JPG|.jpeg|.JPEG)$"
- picking the file extensions you need.
And then set 'errormessage' to whatever you like...
Note: Ensure the file-input control is set as runat="server".
 
W

Wayne Wengert

Thanks for the suggestion. I'll give that a try. I guess the accept property
just isn't supported.

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top