当前位置:网站首页>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;
}
、
边栏推荐
- 【电赛训练】红外光通信装置 2013年电赛真题
- 【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
- js变量提升(hoisting)
- Serialization, listening, custom annotation
- 樹結構---二叉樹2非遞歸遍曆
- ES6 decoupling top-level objects from windows
- JS rewrite their own functions
- [video game training] real topic of 2013 video game of infrared optical communication device
- 手指点击屏幕就模拟进入F11进入全屏
- How to manage fixed assets efficiently in one stop?
猜你喜欢
![[pytorch] 2.4 convolution function nn conv2d](/img/eb/382a00af5f88d5954f10ea76343d6e.png)
[pytorch] 2.4 convolution function nn conv2d

How to launch circle of friends marketing and wechat group activities

队列的实现和应用

2.2 【pytorch】torchvision.transforms

Jetson Nano 安装TensorFlow GPU及问题解决

I use flask to write the website "one"

3D printing Arduino four axis aircraft

FAQ | FAQ for building applications for large screen devices

2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据

nacos简易实现负载均衡
随机推荐
Key points of NFT supervision and overseas policies
js valueOf 与 toString 区别
Niuke monthly race 22- collect pieces of paper
js作用域链与闭包
Yidian Yidong helps enterprises to efficiently manage equipment and improve equipment utilization
Set the type of the input tag to number, and remove the up and down arrows
JS variable lifting
JS prototype chain
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
韦东山板子编译内核问题解决
计网01-物理层
delete和delete[]引发的问题
序列化、监听、自定义注解
Bird recognition app
JS scope chain and closure
Understanding and implementation of AVL tree
Record a redis timeout
2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
How to solve the problem of fixed assets management and inventory?
I use flask to write the website "one"