I'm trying to assign the value of <input type="file" id="field1"> to <input type="file" id="field2">.
I'm having the following code but it is not working as expected:
<script type="text/javascript">
function test(){
var field_value = document.getElementById('file1').value;
document.getElementById('file2').value = field_value;
}
</script>
<body>
<input type="file" onchange="test()" id="file1"/>
<input type="file" id="file2"/>
</body>
Explanation: When I click on the browse field of file field having id="file1" it calls test() function. Variable field_value is having the name of the file uploaded. But it is not assigning the value to file field having id="file2".