是否有可能重新填充用户以前选择的文件选择表单字段 [英] Is it possible to re-populate a file select form field with what the user previously selected
问题描述
编辑:实际上,Firefox有一个选项可以在about:config中启用它。但它是默认禁用的,其他浏览器AFAIK没有这个选项,所以它是不相关的。
另外,你也许可以用Flash来实现这个可以创建比纯HTML / JS更高级的上传框,但是我不确定是否有这样的限制。您可能需要查看 SWFUpload 。
I have a form with a file select field. If the user submits the form, but there is a problem with one of the fields, it would be nice to have the file select field "repopulated" with the previous selection. I'm fairly certain that because of browser security policies this is impossible, but maybe there is a workaround out there that I'm unaware of.
It can't be done from security reasons. If JS or HTML could set the file path, any webpage could create a bunch of invisible file upload boxes and literally leech files from your hard disk. Without you knowing.
EDIT: Actually, Firefox has an option to enable this in about:config. But it is disabled by default and other browsers AFAIK don't have this option, so it is irrelevant.
Also, you might be able to achieve this with Flash - it can create some more advanced upload boxes than plain HTML/JS, but I'm not sure whether it has such limitation or not. You may want to check out SWFUpload.
这篇关于是否有可能重新填充用户以前选择的文件选择表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!