我如何“保持”上传的图片上的表单验证错误? [英] How can I "keep" the uploaded image on a form validation error?
本文介绍了我如何“保持”上传的图片上的表单验证错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单,其中包含一个 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屋!
查看全文