Hook on the change
event of the file field.
<form method="post" enctype="multipart/form-data">
<input type="file" onchange="this.form.filename.value = this.value">
<input type="text" name="filename">
</form>
Jsfiddle demo. Note that IE6/7 incorrectly gives the full path while other browsers correctly gives only the filename.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…