简体   繁体   English

Django上传图片错误

[英]Django uploading image error

I'm trying to upload an image using normal form for normal admin for normal model with normal image field. 我正在尝试使用具有正常图像字段的正常模型的正常管理员的正常形式上载图像。

thumb = fields.ThumbnailField(upload_to=make_upload_path, sizes=settings.VIDEO_THUMB_SIZE, blank=True, null=True)

But I'm getting an error: 但是我遇到一个错误:

Upload a valid image. The file you uploaded was either not an image or a corrupted image.

But my images are valid! 但是我的图片是有效的! I've tried at least ten jpegs and getting the error. 我尝试了至少十个jpeg并收到错误消息。 What can I do? 我能做什么?

You probably have PIL (Python Imaging Library) installed without JPEG support. 您可能安装了不支持JPEG的PIL(Python影像库)。 If you don't have the libjpeg header files it'll happily compile and install, just with no JPEG support. 如果没有libjpeg头文件,它将很高兴地编译和安装,而没有JPEG支持。 You need to uninstall PIL, make sure you install libjpeg and the libjpeg development header files, and then reinstall PIL. 您需要卸载PIL,确保安装了libjpeg和libjpeg开发头文件,然后重新安装PIL。 How you do this depends entirely on your platform. 您如何执行此操作完全取决于您的平台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM