javascript - 当输入 ="file"时,如何获得预选输入?

标签 javascript php html file file-upload

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/

阅读以下文章How to set a value to a file input in HTML?

关于javascript - 当输入 ="file"时,如何获得预选输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25923141/

相关文章:

php - 获取有帖子的用户

c# - 将图像放在 HTML 5 中的 div 中

html - ^C 字符从 photoshop 复制和粘贴文本后

html - 使我的 DIV 响应

javascript - 基本的passport.js 注册功能失败,认为用户名已被占用

php - 检查用户是否在数据库中

javascript - 如何在vscode的外部文件中获取express中间件的智能感知?

php - Bud1%@@@@E%DSDB`@@@是什么?

javascript - 加载所有元素后更新背景

javascript - 如果 Javascript 的原生 OOP 是无类的,那么构造函数呢?这不是意味着一个类吗?