0

This has happened to me the before. Previously I used beforeSend option to send token before ajax request, however this time I am using dropzone and I don't want to mess with its code (if there is a proper way to override some of its functionality without effecting other scripts, i'd love to know). I've searched for the solution in laravel's documentation, laracasts, here and other google search results, in all most all the questions the answer is use $.ajaxSetup() and set the header of X-CSRF-TOKEN, but the thing is this does not work for me, I tried it the previous time and I've tried it this time. Can someone please help, again $.ajaxSetup() doesn't work and dropzone is making the ajax request so i'm not sure if beforeSend is an alternative.

jrbedard
  • 3,662
  • 5
  • 30
  • 34
sujan basnet
  • 190
  • 2
  • 12

1 Answers1

0

If you use this code block between your form tag, the problem may be resolve. It's work for me.

<input type="hidden" name="_token" value="{!! csrf_token() !!}">
                    @foreach($errors->all() as $error)
                        <p class="alert alert-danger">{{$error}}</p>
                    @endforeach
                    @if (session('status'))
                        <div class="alert alert-success">The file was saved successfully.</div>
                    @endif

And this steps gives the best result for me

[https://tuts.codingo.me/laravel-5-1-and-dropzone-js-auto-image-uploads-with-removal-links/][1]