django-ajax-uploader how to send csrf_token with fine-uploader 3.5.0 -


i implementing django-ajax-uploader in project, want use latest version of fineuploader under 3.5.0, supposedly, documentation says thing should send csrf_token putting inside customheaders dictionary:

if want use latest version of fine uploader, valum's file-uploader called, instead of 1 bundled django-ajax-uploader, can replacing params arguments in above template following customheaders:

customheaders: { 'x-csrftoken': '{{ csrf_token }}', },

here full code:

...             <h1>qq-file-uploader</h1>         <div id="upload-button" class="btn btn-primary"><i class="icon icon-cloud-upload icon-white"></i> selecciona un archivo</div>         <div id="file-upload"></div>     </form> {% endblock %}  {% block styles %}     <link rel="stylesheet" type="text/css" href="{{ static_url }}js/libs/jquery.fineuploader-3.5.0/fineuploader-3.5.0.css"/> {% endblock %}  {% block javascript %}     <script type="text/javascript" src="{{ static_url }}js/libs/jquery.fineuploader-3.5.0/jquery.fineuploader-3.5.0.min.js"></script>     <script type="text/javascript">         $(function(){             $('div#file-upload').fineuploader({                 customheaders: {                     'x-csrftoken': '{{ csrf_token }}'                 },                 request: {                     endpoint: '{% url 'documents:qq_file_uploader' %}'                 },                 button: $('div#upload-button'),                 multiple: false,             });         });     </script> {% endblock %} 

in views.py have: qq_file_uploader = ajaxfileuploader()

and everytime try upload file within view got 403 error: csrf verification failed. request aborted.

use request.params set token , sent via post.

... request: {     endpoint: '{% url 'documents:qq_file_uploader' %}',     params: {         'csrfmiddlewaretoken': '{{ csrf_token }}'     } }, ... 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -