更新时间:2021-06-28 22:55:28
在表格下方添加此内容。
Add this in below inside the form.
// This will generate token field which will be token
{{ csrf_field() }}
// Expected Output
<input type="hidden" name="_token" value="ssdfdsfsdfsdfs32r23442">
VerifyCsrfToken.php
- 文件是 middleware 将自动验证请求输入中的标记
是否与存储的标记匹配在会话中。
VerifyCsrfToken.php
- The File is middleware
, which is included in the web middleware group, will automatically verify that the token
in the request input matches the token stored in the session.
请参阅此URL以获取更多信息:
http://laravel.com/docs/master/routing#csrf-x-csrf-token
Refer this URL for few more information: http://laravel.com/docs/master/routing#csrf-x-csrf-token
更新 - 2016年12月23日
Updates - 23rd Dec 2016
从laravel开始,您可以使用如下所示好吧。
As of laravel, you can use like below as well.
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
API参考: https://laravel.com/docs/master/routing#form-method-spoofing