当前位置:网站首页>A 419 error occurred in the laravel postman submission form. July 6th, 2020 diary.
A 419 error occurred in the laravel postman submission form. July 6th, 2020 diary.
2022-07-01 09:19:00 【What about your long love~】
Studying recently laraveel introduction , Learned the upload and download section , Because I haven't learned about controllers and views yet , So just use it. postman Mock submit form , Uploaded a small file .
But with postman When submitting forms and uploading files , appear 了 419 error , This is because csrf The limitation of . The result of Baidu solution is probably 3 individual
The first is to annotate the middleware :
app\Http\Kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
// Comment out the following line
// \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
The second way is Set the whitelist
app\Http\Middleware\VerifyCsrfToken.php
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/** * The URIs that should be excluded from CSRF verification. * * @var array */
protected $except = [
// Set... Here *
'*'
];
}
this 2 It's true that the function can be realized in three steps , But this 2 All of them are extreme , So I tried to set the white list for a certain method of a certain controller , It is written as follows
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/** * The URIs that should be excluded from CSRF verification. * * @var array */
protected $except = [
// Set... Here *
// '*'
'[email protected]',
'index/index',
'www.blog.com/scc'
];
}
Tried three ways to write All wrong , use postman Upload file or 419 error , Later, the real solution was found .
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/** * The URIs that should be excluded from CSRF verification. * * @var array */
protected $except = [
# This is the way the root is written in Miao Hong .
'scc'
];
}
scc Is the routing ID .
as follows
# Routing rules
Route::any('scc', '[email protected]');
# Method of controller
function scc(Request $request){
// echo csrf_token();
$name = $request->file('filename');
echo '<pre>';
print_r($name->path());
echo '</pre>';
echo '<hr>';
die;
}
、
边栏推荐
- Analysis and solution of JS this loss
- Shell script -for loop and for int loop
- Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
- Flink interview questions
- Shell script -if else statement
- 小鸟识别APP
- js重写自己的函数
- 【pytorch】nn. AdaptiveMaxPool2d
- Installation and use of NoSQL database
- Log4j 日志框架
猜你喜欢

3D打印Arduino 四轴飞行器

js作用域链与闭包
![[interview brush 101] linked list](/img/52/d159bc66c0dbc44c1282a96cf6b2fd.png)
[interview brush 101] linked list

I use flask to write the website "one"

【检测技术课案】简易数显电子秤的设计与制作

Installation and use of NoSQL database

OSPF - virtual link details (including configuration commands)

【pytorch】softmax函数

Understanding and implementation of AVL tree

Vsync+ triple cache mechanism +choreographer
随机推荐
短路运算符惰性求值
Shell script - array definition and getting array elements
How to launch circle of friends marketing and wechat group activities
Youqitong PE toolbox [vip] v3.7.2022.0106 official January 22 Edition
Naoqi robot summary 28
Learning practice: comprehensive application of cycle and branch structure (II)
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
LeetCode 344. Reverse string
美团2022年机试
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
Set the type of the input tag to number, and remove the up and down arrows
laravel postman 提交表单出现419错误。2020年7月6日记。
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
In the middle of the year, where should fixed asset management go?
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
Shell script -select in loop
js变量提升(hoisting)
JS scope chain and closure
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
3D printing Arduino four axis aircraft