The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

value attribute for HTML input element for file upload

For example:

<input type="file" name="myFile" value="/tmp/sample.file" />

I see this in the page source when it's downloaded, but it "/tmp/temp.txt" doesn't appear in the browser entry field, and, when submitting, the browser treats the field as if it were indeed blank.

Looking at the HTML spec, I see no mention of special interactions for file input elements and the value attribute.

This is in Firefox, and Konqueror on Linux, as well is Internet Explorer under Vista.

Is this standard behavior for this kind of input item. If so I'll just have to live with not being able to fill this item in, unless, of course, there's a Javascript solution. Bwa-ha-ha.
A. Nony Mouse
Friday, November 09, 2007
Well, they say when you ask a question you usually find the answer yourself. I kept digging around.

Looking here:

toward the end it says:


Internet Explorer and Netscape do not use the VALUE attribute as the default contents of the input area. Any default value set via HTML is not usable via scripting and the DOM as well (hence it is not listed as 'supported' in any of the browsers.)


Well, you win some and you lose some. I suppose it's a security breach to let the browser pick your files. Suppose (for *nix) that is came with /etc/passwd filled in, just as an example.
A. Nony Mouse
Friday, November 09, 2007
Yup, it's for security.  If you could default the value, you could easily hide the element and have people upload files without even knowing it.
Almost H. Anonymous Send private email
Saturday, November 10, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz