我怎样才能“保持"?表单验证错误上的上传图像? [英] How can I "keep" the uploaded image on a form validation error?

查看:8
本文介绍了我怎样才能“保持"?表单验证错误上的上传图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,其中包含 FileField 以及其他字段.想象一下,用户选择了一个文件,按下提交,另一个字段触发了 ValidationError.当我取回表单时,页面上有错误,用户为文件字段选择的内容已经消失.我可以让它出现吗,还是浏览器的问题?

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?

推荐答案

这是浏览器的问题 - 出于安全原因,您不能预先填充文件输入,否则很容易诱骗用户从他们的系统上传文件没有他们的明确行动.

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.

这篇关于我怎样才能“保持"?表单验证错误上的上传图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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