You are here: Re: HTML Forms, file input. How extensible is it? « HTML « IT news, forums, messages
Re: HTML Forms, file input. How extensible is it?

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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация