I try to upload a TIFF raster image with 5 bands in Django app and I get error message in form : Upload a valid image. The file you uploaded was either not an image or a corrupted image. I am sure that image is valid .

Here the code :

def dataset(request):
    uploadimages = UploadImagesForm(request.POST or None, request.FILES or None)
    if uploadimages.is_valid():
        if request.FILES.get('multipleimages', None) is not None:
            images = request.FILES.getlist('multipleimages')
            for image in images:
                name = str(image)
    return render(request, 'mylist.html', {'uploadimages': uploadimages})


class UploadImagesForm(forms.Form):
    multipleimages = forms.ImageField(label="Upload Multiple Images:",widget=forms.ClearableFileInput(attrs={'multiple': True}), required=False)

Any idea how to fix it ?

  • There is not enough information here. Where is the error coming from? The code that you've posted is not specific enough. Maybe look in the UploadImagesForm object? Or the validators on it, perhaps? If it's code in your Django app, you'll need to trace it through. We can't see any of that code, though! – Alex Leith Feb 25 '18 at 4:28
  • @Alex Leith I have update my question with UploadImagesForm – jessie jes Mar 1 '18 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.