How to Post Laravel Token Hash in Blueimp Jquery File Upload

- 1 answer

Ad

I'm using Laravel 5.1 and Blueimp Jquery File Upload. I'm using my own uploadHandler.

And i have a problem with deleting files: "Token Mismatch Error"

How can i post csrf_token() result while deleting file ?

Ad

Answer

Ad

Since you are using jquery try this:

  1. Add this meta tag to your blade

     <meta name="csrf-token" content="{{ csrf_token() }}">
    
  2. Add this in JavaScript

                // set up jQuery with the CSRF token, or else post routes will fail
    
        $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } });
    

Ad
source: stackoverflow.com
Ad