Skip to content Skip to sidebar Skip to footer

Kendo Upload - Csrf Token With Kendo Ui Jquery

how to add CSRF Token in kendoUpload $('#image').kendoUpload({ async: { saveUrl: 'http://url', } });

Solution 1:

<meta name="_token" content="{!! csrf_token() !!}" />

<inputtype="file" name="files"id="photos" />

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

$("#photos").kendoUpload({
    async: {
        saveUrl: "http://url/save"
    },
    upload: onUpload
});

functiononUpload(e) {
    var xhr = e.XMLHttpRequest;
    if (xhr) {
        xhr.addEventListener("readystatechange", function (e) {
            if (xhr.readyState == 1/* OPENED */) {
                xhr.setRequestHeader("X-CSRF-TOKEN", token);
            }
        });
    }
}

document

Post a Comment for "Kendo Upload - Csrf Token With Kendo Ui Jquery"