How can I “keep” the uploaded image on a form validation error?

怎甘沉沦 提交于 2019-12-19 16:07:11

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/6199072/how-can-i-keep-the-uploaded-image-on-a-form-validation-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!