473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HTML Forms, file input. How extensible is it?

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!

Oct 19 '05 #1
2 1441
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/
Oct 19 '05 #2
Thanks Benjamin!

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

Oct 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of...
2
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
0
by: sharif | last post by:
Anyone could help me out for n=my code ......I have written following code ,Here i m able to get and post the form successfuly..but after posting im not gettng proper response content... ...
11
by: nickyeng | last post by:
I have a html file contains a form asking user to select a choice and press enter to pass the data to server. In server there, i have a cgi script(C language) that accepts the input from browser...
7
by: thersitz | last post by:
I can't seem to get my html form to submit properly from within a web form. Here's my form tag syntax and some delivery hidden fields. <form id="myForm"...
8
by: =?Utf-8?B?U2hhd24gUmFtaXJleg==?= | last post by:
I am coming at the world from the standpoint of a veteran ASP Classic developer. I am not clear on the advantages of using the ASP.NET control over standard HTML control. With the ASP.NET...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.