小编Dmi*_*try的帖子

如何在django ImageField中验证图像格式

我们的项目使用Python 2.7,PIL 1.1.7和Django 1.5.1.有一个ImageField适用于许多图像格式,包括bmp,gif,ico,pnm,psd,tif和pcx.但是要求只允许png或jpg图像.怎么做到呢?

UPD.我知道我可以验证文件扩展名和http Content-Type标头.但这两种方法都不可靠.我问的是,是否有办法检查上传的文件内容是否为png/jpg.

python django python-imaging-library

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

django ×1

python ×1

python-imaging-library ×1