AJAX를 통해 게시 할 때 Dropzone에 토큰이 포함되지 않은 것처럼 보입니다. 당신은 .... 그렇게 할 수 있도록하기 위해이 같은 것을 사용할 수 있습니다
Dropzone.options.imgUpload = {
paramName: "file",
dictDefaultMessage: "Pošalji sliku",
acceptedFiles: "image/*",
previewsContainer: ".dropzone-previews",
uploadprogress: function(progress, bytesSent) {
console.log(progress);
},
sending: function(file, xhr, formData) {
// Pass token. You can use the same method to pass any other values as well such as a id to associate the image with for example.
formData.append("_token", $('[name=_token']).val()); // Laravel expect the token post value to be named _token by default
}
};
내가 여기에 조각을 발견
...
http://laravel.io/forum/04-17-2014-tokenmismatchexception-with-dropzonejs
을 통해 제출 된 토큰 및 양식 일부 문제가있는 것처럼도 보인다 AJAX. 이 경우 dropzone을 초기화 할 때 추가 헤더를 포함해야합니다.
Dropzone.options.imgUpload = {
paramName: "file",
dictDefaultMessage: "Pošalji sliku",
acceptedFiles: "image/*",
previewsContainer: ".dropzone-previews",
headers: {
"X-CSRF-Token": $('[name=_token').val())
},
uploadprogress: function(progress, bytesSent) {
console.log(progress);
}
};
그리고 이것을 활용, 우리는 AJAX를 통해 제출하는 경우 해당 헤더를 확인하기 위해 filters.php
에 CSRF 필터를 수정합니다.
Route::filter('csrf', function()
{
$token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token');
if (Session::token() != $token) {
throw new Illuminate\Session\TokenMismatchException;
}
});
UploadsController 생성자에서 필터를 설정하고 있습니까? 즉 ... '$ this-> beforeFilter()' – user3158900
경로에 전역 보호 기능을 추가했습니다 : Route :: when ('* ','csrf ', array ('post ','put ','delete ')); – Alen