HTML Forms, file input. How extensible is it?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,
We use
<input type="file"   name="FILEFILENAME" value="">
to get file input dialogs. My questions are:

(1) Is it possible to add a bunch of file filters to the opening dialog
box? (*.txt, *.doc, etc etc)

(2) Is it possible to get the type of file selected in the dialog?
Meaning the index of the element if (1) is possible, so that you could
mess around with it in the java script.

If both the above are not possible... is anyone at the W3C thinking
about adding this neat feature into the HTML spec in the near future?
Anyone? :)


Re: HTML Forms, file input. How extensible is it?

Mongoose wrote:

Quoted text here. Click to load it

There is the 'accept' attribute for the INPUT element which takes a list of
MIME types (not file suffixes). Don't know if this is handled by any

Quoted text here. Click to load it

You could look at the selected filename (in fact it could be a list of
filenames, but most browsers do not support selecting multiple files...) at
see, if it has a known suffix. But keep in mind that the connection between
filetype and suffix is pretty arbitrary and that there are operating
systems that do not use this concept at all.
The only reliable way to determine the filetype is by looking at the file
contents, e.g. using the UNIX 'file' tool. And you have to do this on the
server side of course.

Benjamin Niemann
Email: pink at odahoda dot de
WWW: /

Site Timeline