I have a form which has a FileField
among other fields. Imagine the user chooses a file, presses submit and another field triggers a ValidationError. When I get back the form, with the errors on the page, what the user chose for the file field is gone. Can I make it appear, or is this a browser thing?
我有一个表单,其中包含FileField和其他字段。想象一下,用户选择一个文件,按下提交,另一个字段触发ValidationError。当我返回表单时,如果页面上出现错误,用户为文件字段选择的内容就不见了。我可以让它出现,还是浏览器?
1 个解决方案
#1
7
This is a browser thing - for security reasons, you can't prepopulate a file input, otherwise it would be easy to trick users into uploading files from their system without their explicit action.
这是一个浏览器 - 出于安全原因,您无法预先填充文件输入,否则很容易诱使用户在没有明确操作的情况下从系统上传文件。
#1
7
This is a browser thing - for security reasons, you can't prepopulate a file input, otherwise it would be easy to trick users into uploading files from their system without their explicit action.
这是一个浏览器 - 出于安全原因,您无法预先填充文件输入,否则很容易诱使用户在没有明确操作的情况下从系统上传文件。