Kendo 上传 - 使用 kendo ui jquery 的 CSRF 令牌
Kendo Upload - CSRF Token with kendo ui jquery
how to add CSRF Token in kendoUpload
$("#image").kendoUpload({
async: {
saveUrl: "http://url",
}
});
<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);
}
});
}
}
how to add CSRF Token in kendoUpload
$("#image").kendoUpload({
async: {
saveUrl: "http://url",
}
});
<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);
}
});
}
}