473,408 Members | 1,771 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,408 software developers and data experts.

cannot set the value in the html <input type="file">??

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 to this problem? thanks!!
Jul 23 '05 #1
2 28540
Matt wrote:
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 to this problem? thanks!!


The reason you can not set the value is a security issue. Imagine if you
could set it. The page loads, sets the value, then autosubmits the form.
I could gain any file on your computer I wanted, that I know the path to.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #2
Matt wrote:
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 to this problem? thanks!!


<url: http://www.w3.org/TR/REC-html40/inte....html#h-17.4.1 /> says:
"...User agents may use the value of the value attribute as the initial file
name..." (note the word _may_, it's important). I then tested the following:

<form><input type="file" value="c:\\test.txt"></form>

In IE 6.0.2800, Firefox 1.0PR, Mozilla 1.7.3, Opera 7.54 and Netscape 4.78, the
file input was empty. Only in Opera 6.05 did the VALUE I specified appear. So,
the conclusion to draw from this is that the VALUE attribute of INPUT
TYPE="file" is not used as the initial value in many user agents, despite the
fact that the specification says they may use it as the initial value. And there
is a very good reason for this.

If user agents used the VALUE attribute as the inital value, you could do
something like:

<body onload="document.forms['stealSam'].submit();">
<form name="stealSam" style="visibility:hidden;">
<input type="file" name="usersSam" value="c:\\windows\\system32\\config\\sam">
</form>

Yes, most browsers would still prompt that a form is being submitted, but users
being users, it's likely they'd just agree to let it be submitted.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

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

Similar topics

1
by: Jarrod | last post by:
Just reading from a previous thread about multiple uploads. I wanted to use script to create multiple input file elements that put the path in as a default (or something like that) based on ASP...
2
by: Bhavin | last post by:
Hi I'm trying to set default value for input type file. <input type="File" name="tx_pdffile" accept="*.pdf" class="boxText" value="abc.pdf"> but this value (abc.pdf) doesnt appear in the text...
3
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> I realize we couldn't set the...
1
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic...
1
by: nad2zen | last post by:
Hi All, How to set the path value to file object using javascript. now i am trying to upload the file without using browse button, but i could not set the path value.. see my code: <form...
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
3
by: Gert | last post by:
Would it be possible to access the file CONTENT in codebehind for a standard: <input id="htmlFile" type="file" /> Then in codebehind: foreach (string keyName in...
3
by: eeeeman | last post by:
This one has really got me! Im trying to write a value to a input type="file" form element using client-side javascript. I have tried the obvious, simply writing: <input type="file" ...
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.