Is there a way to use JavaScript to set the file name and contents of a form's file uploads?
For example, suppose we have two file input elements.
<input type="file">
<input type="file">
Can JavaScript copy the content from one form element to the other?
Add an onchange event on any of the input type file
Get its file property and assign to other input like
element2.files = element1.files;
var el = document.getElementById("1");
var el1 = document.getElementById("2");
el.onchange = function(){
el1.files = el.files;
}
<input type="file" id="1">
<input type="file" id="2">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With