Standard File dialog filters

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
agadgil
Forum Newbie
Posts: 7
Joined: Thu Aug 28, 2003 6:02 am

Standard File dialog filters

Post by agadgil »

I need to display a standard file dialog which can allow me to browse in files. I do use input type = file, such that a standard file dialog is displayed. But the filter is defaulted to "All files". I want to chnage it to "Picture files". Any suggestions.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

try something like this

Code: Select all

<input name="file" type="file" accept="image/gif">
Just change the MIME type to suit.

You can add multiple MIME types separated by a comma.

Unfortunatley, most modern browsers ingnore the accept= parameter. As a suggestion, you could code this function into the upload script to screen for file type, if the file is an picture file then go ahead and accept it, if it isn't a picture file then spit out a message that only picture files are accepted for upload.


Mark
Post Reply