Click here to get back home

HTML Forms, file input. How extensible is it?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
HTML Forms, file input. How extensible is it? Mongoose 10-19-2005
Posted by Mongoose on October 19, 2005, 2:12 am
Please log in for more thread options


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? :)

Thanks!



Posted by Benjamin Niemann on October 19, 2005, 3:02 pm
Please log in for more thread options


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/

Posted by sukitha on October 22, 2005, 2:01 am
Please log in for more thread options


Thanks Benjamin!

Yes most browsers dont support the 'accept' (alteast firefox (hence
mozilla) and IE
dont.


Similar ThreadsPosted
in Firefox March 19, 2008, 9:57 pm
Manipulating a forms input border December 28, 2005, 1:09 pm
File Uploads using October 13, 2004, 9:19 pm
& in one action? April 4, 2005, 6:34 am
forms: _not_ uploading a file November 16, 2004, 1:52 pm
February 21, 2008, 12:21 pm
input type="file" question February 4, 2005, 12:02 am
Testing a file-type input element April 11, 2007, 12:43 am
automatically put a default filename in value October 18, 2005, 1:56 am
Is XHTML actually eXtensible? August 25, 2004, 11:39 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap