How do I copy the value of a file input in an HTML form to another file input on a

J L

New member
different form, same page? I'm missing attributes on the form elements, but you get the idea ;)

calling copy() throws a DOM security exception.

Reading online, i'm not allowed to overwrite the value property with a string so that I can't set it to whatever file, which makes sense. But why can't I set it to a value that the user already specified? I woudl imagine its some sort of special class object that I can't access, but can pass around. Thoughts?

<script>

function copy()
{
document.form2.file2.value = document.form1.file1.value;
}
</script>
<body>
<form name="form1">
<input type="file" name="file1" id="file1"/>
</form>

<form name="form2">
<input type="file" name="file2" id="file2"/>
</form>
 
Back
Top