|
Posted by Benjamin Niemann on 10/19/05 16:02
Mongoose wrote:
> 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)
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
browser.
>
> (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.
No.
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: http://www.odahoda.de/
[Back to original message]
|