472,802 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Setting a FILE INPUT element


How do I set a file input element? If it's a text input, I can set the
value property. But this doesn't work with file inputs.

And no, I can't change it - I'm writing a script to automate a process
on an existing system.

Jim Witte
Indiana University CS
Jul 23 '05 #1
2 7192
Jim Witte wrote:

How do I set a file input element? If it's a text input, I can set the
value property. But this doesn't work with file inputs.

And no, I can't change it - I'm writing a script to automate a process
on an existing system.

Jim Witte
Indiana University CS

How do you mean, how can you set a file input element? Are you using
<input type="file"> and want to specifiy a default file/path?

If this is true, you shouldn't be able to - more because of a security
precaution... I asked a similar question sometime last year and the
response to my post was that most web browsers wouldn't permit such.

In addition, I have the O'Reilly Javascript Pocket Reference which, on
page 92 says "Note that for security reasons, the value property of
elements of type "file" is usually read-only."

Note the word is "usually" (their choice of words, not mine) - you might
find it possible with one or two browsers but it won't be reliable.

Does that help you any?

Jul 23 '05 #2
Jim Witte wrote:
How do I set a file input element? If it's a text input, I can set the
value property. But this doesn't work with file inputs.



Input Type=File
Browser Peculiarities

* 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.) If a user enters text in the field
however, that value is then reachable via the DOM as it normally would
be for a normal INPUT field (via the .value property.) The reason for
this behavior would presumably be to ensure the security/safety of users
against malicious authors. Opera displays the default VALUE attribute
value and submits it as well (although it prompts for confirmation on
submit if you have not altered that value.)

* Netscape 2+ only supports the onChange event handler attribute in
cases where the user enters or modifies text via the text box; if the
"Browse..." button is the only thing used, the event is not fired.
Internet Explorer 4.0+ fires the event in both cases.

* Netscape 4+ allows some Character-level formatting to be applied to
the contents of this form field. These physical formatting elements
(along with virtual formatting elements that are rendered identically,
such as EM and I) apply to this form field: I, U, S, STRIKE, SUB, SUP,

* Using a READONLY attribute in IE4 and IE5 on this element still allows
a user to invoke the file...open dialog (from the "Browse..." button),
although the text field is not directly editable. In IE5.5 plus, both
the text field AND the file...open dialog are not usable.

* Opera 5/6: Using the DISABLED attribute still sends the name/value
pair for the element to the form processing script. It should not do this.

Jul 23 '05 #3

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

Similar topics

by: netclectic | last post by:
I'm dynamically adding options to a select list in javascript and i need to be able to set the height of the option, but setting style.height has not effect, I also tried style.pixelHeight but no...
by: moonriver | last post by:
In a xml file, can we make reference to another xml file so that all contents of the latter xml file will be included into the first xml file? Had better give me an example for details.
by: Dave56 | last post by:
Hi. I know how to use <input type=file runat=server> to upload a file to the webserver. However, my files are 2gb and I don't want to up load them. What I would like to be able to do is to...
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory...
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
by: Defected | last post by:
Hi All, I have need to write a void function that will merge the contents of two text file containing chemical elements sorted by atomic number and will produce a sorted file of binary records....
by: Sebarry | last post by:
Hi, I'm using the following code from the-stickman.com to create a file upload list in Javascript. I want to modify it so that the file element is only added if the user has provided a description...
by: rsaharia | last post by:
Hello All, I need help with this particular .pl file I picked up from http://www.veritools-usa.com/xnf2vhdl.htm What it's supposed to do is really convert an xnf file to a vhdl file. I need it for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.