How to set value in an <input type="file"> tag before the page loads?

How to set value in an <input type=“file”> tag before the page loads?
If I use this HTML code:


<input name="imagefile" type="file" value="C:\\WebServers\\Gazeta\\images\\29\\Banner.gif">

This <input> tag asks a user to select a file from his local computer.
I need to set this value before the page loads,

As you see, I set it to:


value="C:\\WebServers\\Gazeta\\images\\29\\Banner.gif"

But it doesn’t work,
the text is empty.
Where am I wrong?

Thank you.

Hmm… I’ve never tried to, but I don’ think you can.

I’m about to leave the office, so I’ll do some research when I get home.

:slight_smile:

Weird, the HTML 4.01 specifications says that VALUE should be accepted. I can’t get it to work either. I am using IE6. Not working in NS 6 or Navigator 4.08, either.

Creates a file select control. User agents may use the value of the value attribute as the initial file name.

http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT

I don’t think you can. It’s a security issue. If you were allowed to do this, you could upload any file from the user’s drive without them knowing: just put the <input> in a hidden div, preset the value to the file you want, then submit the form to your serverside script using javascript onload :eek:.

Jon

I’m new to Javascript, could you, PLEASE, give me
an example how to set this value useing javascript onload ?

Thank you

<script language=“JavaScript”>
<!–
function LoadValue() {
FormName.FormField.value=‘C:\location\of\file.gif’;
}
–>
</script>

<body OnLoad=“LoadValue();”>

My point was that you can’t, even with javascript. I was giving a scenerio of what you could do [em]if[/em] you were allowed to do this.

Sorry for any misunderstanding.

Why would you need this anyways? The user could have the file anywhere on their computer, or, they may not even have the file at all.

I’m making a site for our local newspaper.
I have a page which adds new article to this newspaper.
and this page has a field for selecting a picture as the main “heading”.
But if a user finds en error in his articale then he should be allowed to edit this articale.
And he must select this picture once again to complete
this editing.( this is annoying for user).
He wants to edit the “text” not the “picture”.