Note:
The answers & comments below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element dynamically/programatically using JavaScript and a dataTransfer or FileList object in 2017.
See the answer in this question for details as well as a demo:
How to set file input value programatically (i.e.: when drag-dropping files)?
如何设置此值?
<input type="file" />
你不能
设置文件输入值的唯一方法是由用户选择文件。
这是出于安全考虑。否则,您将能够创建一个Javascript,自动从客户端计算机上载特定文件。
不是对你的问题的回答(其他人已经回答了),但是如果你想拥有上传文件字段的一些编辑功能,你可能需要做的是:
<input>
标记你不能因为安全原因。
想象一下:
你不希望你访问的网站能够做到这一点,是吗?=)
相关问题 更多 >
编程相关推荐