我使用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