Django - forms.FileField() 初始值 [英] Django - forms.FileField() initial value

查看:18
本文介绍了Django - forms.FileField() 初始值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以动态地为 forms.FileField() 赋予初始值?

Is it possible to give initial value for forms.FileField() dynamically?

推荐答案

根据安全标准, 不能有默认值,也不能被操纵.

By security standards, <input type="file"> can't have a default value and it can't be manipulated.

原因是,黑客可以将文件输入的默认值设置为您系统上的任何重要文件(包含密码、证书等),使用 CSS 隐藏此字段,您将永远不会知道您已上传黑客托管的东西.

The reason is, that a hacker can set the default value of the file input to any important file on your system (containing passwords, certificates and so on), hide this field using CSS and you will never know that you have uploaded something to hackers host.

这篇关于Django - forms.FileField() 初始值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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