Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Django CSRF verification failed. Request aborted. error

I'm trying to upload an image using dropzone.js, but its not using login or register. I get CSRF verification failed. Request aborted.

Dropzone.options.fileDropzone = {
  url: '/media/',
  init: function() {
    this.on("error", function(file, message) {
      alert(message);
      this.removeFile(file);
    });
    var submitBtn = document.querySelector("#submitBtn");
    var myDropzone = this;
    submitBtn.addEventListener("click", function() {
      console.log("upload");

      myDropzone.processQueue();
    })
  },
  autoprocessQueue: true,
  clickable: true,
  thumbnailHeight: 90,
  thumbnailWidth: 115,
  maxFiles: 1,
  maxFilesize: 10,
  parallelUploads: 1,
  addRemoveLinks: true,
  dictRemoveFile: 'delete',
  uploadMultiple: false,

}
<form class="imageUploaderForm" method="post" id="upload" enctype="multipart/form-data">
  {% csrf_token %}
  <div class="form-title">Upload your Image</div>
  <div class="upload-type">File should be Jpeg, Png, Gif</div>
  <div class="dropzone" tabindex="0" class="drop-zone" style="border-style: dotted;" id="fileDropzone">

    <input accept="image/jpeg, image/png, image/gif" multiple="" type="file" autocomplete="off" tabindex="-1" name="myFile" class="drop-zone-input" style="display: none;">
    <div class="placeholder">
      <img class="hide" width="115" height="90" src="#" id="preview">

    </div>
  </div>
  <span style="color: rgb(169, 169, 169);">or</span>

</form>

and i used

var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');

and

headers: { 'x-csrf-token': CSRF_TOKEN, },

this two codes but it's still have same error

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try using the following:

headers: {
        'X-CSRF-TOKEN': $("input[name=csrfmiddlewaretoken]").val()
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!