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 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>
标记在哪里,当用户提交表单时,它仍然会显示之前选择的文件?
我尝试过以下方法:
<input type="file" name="upfile" value="<?=isset($_POST['upfile'])?$_POST['upfile']:''?>"/>
但似乎不起作用!
最佳答案
对于输入类型文件,无法设置默认值。您必须使用一些插件,例如http://blueimp.github.io/jQuery-File-Upload/
关于javascript - 当输入 ="file"时,如何获得预选输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25923141/