473,468 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting a FILE INPUT element

Hi,

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
js*****@bloomington.in.us
Indiana University CS
Jul 23 '05 #1
2 7229
Jim Witte wrote:
Hi,

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
js*****@bloomington.in.us
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?

laters
randelld
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.

<snip>

http://www.blooberry.com/indexdot/ht...e.htm#peculiar

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,
BIG, SMALL, FONT SIZE and FONT FACE.

* 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

9
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...
1
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.
3
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...
6
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...
1
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...
1
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"...
7
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....
1
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...
4
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.