我使用dropzone.js將圖像上傳到我的網站,但Laravel總是報告TokenMismatchException,儘管我在表單中使用了Form::open()
,它自動添加了_token
。Laravel-Tokenmissmatchexception with Dropzone.js
這是我的代碼:
{{ Form::open(["class" => "dropzone", "id" => "imgUpload", "action" => "[email protected]"]) }}
<div class="fallback">
{{ Form::submit() }}
</div>
{{ Form::close() }}
JS
Dropzone.options.imgUpload = {
paramName: "file",
dictDefaultMessage: "Pošalji sliku",
acceptedFiles: "image/*",
previewsContainer: ".dropzone-previews",
uploadprogress: function(progress, bytesSent){
console.log(progress);
}
};
如何解決這個問題?
您是否在'UploadsController'構造函數中設置了任何過濾器?即...'$ this-> beforeFilter()' – user3158900 2014-09-02 15:45:44
我在路由中添加了全局保護:Route :: when('*','csrf',array('post','put','delete')); – Alen 2014-09-02 15:47:55