468,103 Members | 1,255 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

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 7610
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jesper Hermansen | last post: by
2 posts views Thread by IkBenHet | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.