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

input type="file"

Sorry if my question was be here earlier, I'm new here ;-)

I have html form where is the tag
<input id="x" type="file" name="upload">
and another fields. After submit script on server take some validation on
some fields and if te error is found the same form is generated with error
reporting message. But the content of the "file" input is lost. I test it in
IE6 and parameter value="???" not work here. I try to put string into input
using javascript but this not work too. Is possible to emulate keyboard
typing in javascript? My idea is something like this

o=document.GetElementById('x');
o.focus();
window.type('c:\pictures\picture.gif');

The last line is non existing command, but exist some like this?
Or anybody have another idea how to fill file-type input?
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Aug 3 '06 #1
4 7832
Petr Vileta wrote:
Sorry if my question was be here earlier, I'm new here ;-)

I have html form where is the tag
<input id="x" type="file" name="upload">
and another fields. After submit script on server take some validation on
some fields and if te error is found the same form is generated with error
reporting message. But the content of the "file" input is lost. I test it
in IE6 and parameter value="???" not work here. I try to put string into
input using javascript but this not work too.
Browsers don't let webpages specify values for file inputs. It prevents such
abuses as
<input type="file" name="x" value="c:\Quicken\CreditCardInformation.file"
style="display: none;">
Or anybody have another idea how to fill file-type input?
You can't.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 3 '06 #2
On 03/08/2006 22:45, Petr Vileta wrote:
Sorry if my question was be here earlier, I'm new here ;-)
Your question is a markup issue, and better addressed to a group that
focuses on HTML, but...
I have html form where is the tag
<input id="x" type="file" name="upload">
and another fields. After submit script on server take some validation
on some fields and if te error is found the same form is generated with
error reporting message. But the content of the "file" input is lost.
For security reasons, the value attribute is ignored for input elements
of type file.

Consider, for instance, if the default value was set to a known,
security- or privacy-related file. The form could auto-submit, or
contain a control hidden within a seemingly innocuous form using CSS,
thereby uploading the file without the user's permission. For the same
reason, a client-side script is not permitted to manipulate the value.

[snip]
o=document.GetElementById('x');
For future reference, the method name begins with a lower case 'g'.

Mike
Aug 3 '06 #3
"Michael Winter" <m.******@blueyonder.co.ukpíše v diskusním příspěvku
news:02*******************@text.news.blueyonder.co .uk...
On 03/08/2006 22:45, Petr Vileta wrote:
>I have html form where is the tag
<input id="x" type="file" name="upload">
and another fields. After submit script on server take some validation on
some fields and if te error is found the same form is generated with
error reporting message. But the content of the "file" input is lost.

For security reasons, the value attribute is ignored for input elements of
type file.
Grr :-)
>
>o=document.GetElementById('x');

For future reference, the method name begins with a lower case 'g'.
Off course ;-) My typos.
But back to the problem. Is a way to emulate user keyboard typing? Some like
Windows macros or put some into system clipboard using javascript and later
to do the Paste in form file?
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Aug 3 '06 #4
Petr Vileta said the following on 8/3/2006 7:06 PM:

<snip>
But back to the problem. Is a way to emulate user keyboard typing?
No, for the same reasons.
Some like Windows macros or put some into system clipboard using javascript
and later to do the Paste in form file?
No, for the same reason. If you could paste it in, you could set it's
value and you can't. Only the user can set that value.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 4 '06 #5

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

Similar topics

1
by: Jesper Hermansen | last post by:
Hi! I'm making a system that will generate Winamp-playlists. To make it easy for the user to add a file to the list, I'm using <input type="file">. The problem with this is that I only get...
2
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> Any ideas? and workarounds...
2
by: Laermans_k | last post by:
Hi, Does anyone have a solution to use the <input type="file" id="filechooser"> and the <input type="submit" id="submitbutton"> in 1 button click? I've already tried to create a javascript...
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...
2
by: IkBenHet | last post by:
Hello, I am uploading a file using this form in ASP.NET. I have also added a simpel textfield: <form runat="server" enctype="multipart/form-data"> <input type="file" id="oFile" Name="oFile"...
2
by: Tarkeshwar | last post by:
Hi All, I want to restrict the user from being entering the value in <input type="file">. It works fine in IE but not in Mozilla. I am sending my code also which works in IE and not in Mozilla.Can...
5
by: cssExp | last post by:
alright suppose i have the following. <input type="file" name="upload" /> <input type="text" name="discription" /> <input type="image" onclick="addFile();" src="images/addfile.jpg" name="add"...
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: sandeep kumar shah | last post by:
Hi, We have used a file uploading HTML tag in an HTML page. We need to customize the text displayed on the Button (which is by default “Browse…” for internet explorer). Below is the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.