Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need tip changing value of form input type="file"

Status
Not open for further replies.

jebo100

Technical User
May 11, 2007
52
0
0
PH
hi,

need a tip.
i wanted to put in a value for my input from an onclick event.

example:

<script type="text/javascript">
function change_value(frm){
frm.elements['file_up'].value="test.jpg"
}
</script>

<form action="trial.php" method="post" enctype="multipart/form-data" name="trial_input">
<input type="file" size="20" name="file_up">
<input type="button" value="val" onclick="change_value(trial_input)">
</form>

the script wont work and my firebug returns a
Security error" code: "1000

please enlighten me :)




JEBO
4saledavao
 
Hi

That would be a security problem. So the only value you can assign to an [tt]input[/tt] of type [tt]file[/tt], is empty string. Of course, there may be some obscure trick in Explorer...

Feherke.
 
Jebo,

Just so you know why you are seeing this... it is because if you could programatically set the value of a file input, users could be tricked into visiting web pages which automatically upload sensitive files from their computer from known locations.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks a lot guys!!!

JEBO
4saledavao
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top