Kendo上传-带有kendo ui jquery的CSRF令牌

问题描述 投票:0回答:1

how to add CSRF Token in kendoUpload

$("#image").kendoUpload({

    async: {
        saveUrl: "http://url",

    }
});
javascript jquery kendo-ui telerik kendo-upload
1个回答
0
投票
<meta name="_token" content="{!! csrf_token() !!}" />

<input type="file" name="files" id="photos" />

   `var token = $('meta[name="_token"]').attr('content');`  $("#photos").kendoUpload({
    async: {
        saveUrl: "http://url/save"
    },
    upload: onUpload
});

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

© www.soinside.com 2019 - 2024. All rights reserved.