Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Pass CSRF token for Laravel Upload Ajax request? #4

Open
devravik opened this issue Nov 2, 2018 · 3 comments
Open

How to Pass CSRF token for Laravel Upload Ajax request? #4

devravik opened this issue Nov 2, 2018 · 3 comments

Comments

@devravik
Copy link

devravik commented Nov 2, 2018

Getting 419 error. How to Pass CSRF token for Laravel Upload Ajax request?

@laliux
Copy link

laliux commented Nov 23, 2018

@devravik

Using v-bind to replace the upload url works for me:

<v-uploader @done="uploadDone" v-bind:upload-file-url="'{{ '/foo/file-upload?_token=' . csrf_token() }}'"></v-uploader>

@icehan2016
Copy link

icehan2016 commented Jan 10, 2019

如果使用组件的 可以这样实现
1 在 blade 中 <meta name="csrf-token" content="{{ csrf_token() }}">
2 在 app.js 中

var csrf_token = document.querySelector('meta[name=csrf-token]').getAttribute('content');

const uploaderConfig = {
    uploadFileUrl: 'api/upload/publicFileUpload?_token='+csrf_token,
    fileTypeExts:  "jpeg,jpg,png",
    showMessage: (vue, message) => {
        vue.$dlg.alert(message);

    }
};

@sonichandni
Copy link

$.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
 });

Try this.. Hope it will help you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants