To copy the selected file name / path to another text field, first use this JS:
function CopyMe(oFileInput, sTargetID) { document.getElementById(sTargetID).value = oFileInput.value; }
And it will work with such HTML:
<div> <input type="file" onchange="CopyMe(this, 'txtFileName');" /> </div> <div> You chose: <input id="txtFileName" type="text" readonly="readonly" /> </div>
Test case: http://jsfiddle.net/yahavbr/gP7Bz/
Note that modern browsers will hide the real full path, showing something like C:\fakepath\realname.txt to show only the name (which is real):
function CopyMe(oFileInput, sTargetID) { var arrTemp = oFileInput.value.split('\\'); document.getElementById(sTargetID).value = arrTemp[arrTemp.length - 1]; }
( http://jsfiddle.net/yahavbr/gP7Bz/1/ )
source share