473,569 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 28561
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.javas cript 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="documen t.forms['stealSam'].submit();">
<form name="stealSam" style="visibili ty:hidden;">
<input type="file" name="usersSam" value="c:\\wind ows\\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*****@agrico reunited.com>
comp.lang.javas cript 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
7523
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 code. My problem was that the input file value property is readonly and there is no default value. The thing is you can cut and paste a path...
2
7499
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 box.. Whats the solution???
3
3081
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 default filename for security reasons, and browsers don't support that. (http://www.cs.tut.fi/~jkorpela/forms/file.html#value). I really need to...
1
3285
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 as this is the reason (security) that I want to restrict their selection. Any help on this one will be greatly appreciated. The page is using...
1
19870
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 name="thisForm" enctype="multipart/form-data"> <table align="center"> <tr> <td align="left"><b>Select a file to upload :</b></td>
7
20856
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 is clicked, or "Enter" is hit in the attached text box. I can get the value of the element. But in Netscape 7, onChange doesn't fire until focus...
3
10379
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 System.Web.HttpContext.Current.Request.Form.Keys) { //i can see keyName = "htmlFile" here as well as the "c:/myfile.txt" for example
3
4356
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" name="filebox" value="myvalue"> ..doesnt work (ok I sound like a newbie) I have tried: document.formUpload.filebox.value = "myvalue"
1
14022
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(); ?> <input type="submit">
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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 we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.