# django.core.exceptions.ValidationError: ["Upload a valid image. The file you uploaded was either not an image or a corrupted image."]

- **ID:** `python/django-file-upload-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

上传的文件不是有效的图片格式或已损坏

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   使用PIL库验证图片：from PIL import Image; Image.open(file).verify()
   ```
2. **** (85% success)
   ```
   model字段改为FileField(upload_to='uploads/')
   ```

## Dead Ends

- **** — Django检查文件内容而非扩展名 (90% fail)
- **** — 只影响内存使用，不影响文件验证 (60% fail)
