write data into <input type="file"> using js
<p>I'm trying to assign the value of <code>&lt;input type="file" id="field1"&gt;</code> to <code>&lt;input type="file" id="field2"&gt;</code>.  </p>

<p>I'm having the following code but it is not working as expected:</p>

<pre><code>&lt;script type="text/javascript"&gt; 
function test(){
   var field_value = document.getElementById('file1').value;
   document.getElementById('file2').value = field_value;
}
&lt;/script&gt;
&lt;body&gt;
  &lt;input type="file" onchange="test()" id="file1"/&gt;
  &lt;input type="file" id="file2"/&gt;
&lt;/body&gt;
</code></pre>

<p>Explanation: When I click on the browse field of file field having <code>id="file1"</code> it calls <code>test()</code> function.  Variable <code>field_value</code> is having the name of the file uploaded. But it is not assigning the value to file field having <code>id="file2"</code>.</p>
