[Django]-Django ajax/jquery file upload


There is a typo in your Javascript. It should read {% csrf_token %} instead of {{ csrf_token }}.

After your comments, I had a closer look at the article you linked.

You need to include the library fileuploader.js. It will replace the placeholder div with the id file-uploader with a form with the proper event handlers. Creating a form in plain HTML will not work.

I suggest that you have a look at the example in the Github repository: https://github.com/alexkuhl/file-uploader/tree/master/client


You need to add return True to the if-statement that checks if it’s raw data, otherwise it will return False even if the upload is successful:

if raw_data:
    foo = uploaded.read(1024)
    while foo:
        foo = uploaded.read(1024) 
    return True

Leave a comment