I have followed the tutorial posted here in order to get AJAX file uploads on my Django app. The thing is that it doesn’t work, and the closest I could get to the issue is finding out that the save_upload() method raises the following exception: ‘WSGIRequest’ object has no attribute ‘read’. Any ideas on what I am doing wrong?
EDIT: I figured out that this is only works in Django 1.3. Any ideeas on how to make it work in Django 1.2?
I think I have gotten to the bottom of your problem.
1) You are trying to run .read() on a request object, which is not allowed. Instead, you need to run it on request.raw_post_data.
2) Before you can run .read(), which takes a file-like object, you need to convert it from a str to a file-like object.
Try this:
…now you’ll be able to run output.read() and get the data you want.