是否有可能重新填充用户以前选择的文件选择表单字段 [英] Is it possible to re-populate a file select form field with what the user previously selected

查看:159
本文介绍了是否有可能重新填充用户以前选择的文件选择表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件选择字段的表单。如果用户提交表单,但其中一个字段存在问题,那么将文件选择字段与之前的选择重新填充是很好的。我相当肯定,由于浏览器的安全策略,这是不可能的,但也许有一个解决方法,那里,我不知道。

解决方案<不能从安全的角度来做。如果JS或HTML可以设置文件路径,任何网页都可以创建一堆不可见的文件上传文件夹,并从硬盘上直接生成leech文件。不知道。



编辑:实际上,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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆