开发者

Validation Error with Multiple File Uploads in Django via Ajax

I have a view to which I am trying to submit multiple ajax uploads via raw post data (e.g. via an octet-stream). These requests are submitted one after the other so that they process in parallel. The problem is that django thinks that only the last request is valid. For example, if I submit 5 files, the first four give:

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

I'm guessing this occurs because somehow the requests overlap? And so the image isn't completely loaded before the form attempts to validate it?

And the last one works fine.

My upload view:

  def upload(request):
    form = UploadImageForm(request.POST, request.FILES)
    print form
    if form.is_valid():
      # ..process image..

And my upload image form:

class UploadImageForm(forms.Form):
    upload  = forms.ImageField()

To submit the requests I'm using the html5uploader js pretty much right out of t开发者_如何学编程he box.


On a different not, have you tried https://github.com/blueimp/jQuery-File-Upload/ - is a pretty good non-flash based file uploader with progress bar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜