ajax - Laravel 发布 - 419 未知状态
问题描述
我正在尝试使用这个包,它可以满足我的一切需求。因此,除了我上传图片时,一切似乎都正常。它根本不会用到 UtilsController@uploadfile 函数。
Route::post('/uploadfile', 'UtilsController@uploadfile');
public function uploadfile(Request $request){
$img = $request->img;
$newlocation = $request->newlocation;
$filename = $request->filename;
return file_put_contents ($newlocation . "/" . $filename , $img );
}
但是当我检查网络时,一切似乎都很好......
我收到此错误:419 未知状态
任何想法?
解决方案
有时可能存在我们可能希望在不需要 CSRF_TOKEN 的情况下存在路由的情况。我们可以简单地在 VerifyCsrfToken 中间件的 except 数组中添加这些 URI 或路由,如下所示
<?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 = [
'stripe/*',
'http://example.com/foo/bar',
'http://example.com/foo/*',
];
}
推荐阅读
- monaco-editor - 移除选线边框
- python-3.x - 忽略顺序合并多列上的数据框
- reactjs - 为什么我在设置 express-csp-header 后在 React PWA 应用程序上收到“default-src: 'none'”内容安全策略错误?
- javascript - 单击链接时React Router不会呈现正确的页面,仅在我刷新页面时才有效
- awk - 有没有办法使用变量而不在“gawk”中使用“echo”?
- javascript - 如何填充变量列表?
- reactjs - 如何在 Express 上设置自定义标头并在 axios 上接收
- python - 错误 Matplotlib 安装请帮助我?
- html - 我们可以在 CSS 中将块放在块中吗?
- sql - 如何在另一列中减去句点