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.
Asked
Active
Viewed 256 times
0

jrbedard
- 3,662
- 5
- 30
- 34

sujan basnet
- 190
- 2
- 12
1 Answers
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]

Gökhan Peker
- 1
- 2
-
the thing is I don't have a form, I don't require a form, itsn't there another way without creating a form, I believe form is redundant if I am posting via ajax. – sujan basnet Jan 13 '17 at 02:11
-
http://stackoverflow.com/questions/30149023/how-to-include-the-csrf-token-in-the-headers-in-dropzone-upload-request – Gökhan Peker Jan 13 '17 at 07:00
-
1Can you try this code in your master head. It may be work. – Gökhan Peker Jan 13 '17 at 07:01