输入文件字段到输入文本字段 [英] Input File field to Input Text field
本文介绍了输入文件字段到输入文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我甚至不知道这是否可行但是有一种方法可以将输入文件字段中所选文件的值转换为输入文本 field?
I don't even know if this is possible or not but is there a method you can take the value of the selected file in a input file field to a input text 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演示。请注意,IE6 / 7错误地给出了完整路径,而其他浏览器只能正确地给出文件名。
Jsfiddle demo. Note that IE6/7 incorrectly gives the full path while other browsers correctly gives only the filename.
这篇关于输入文件字段到输入文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文