laravel - 如何修复使用 File 门面保存文件 Laravel 的错误?
问题描述
我收到以下错误:
{"errors":"Method Illuminate\\Filesystem\\Filesystem::create does not exist."}
进口是:
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
代码是:
$created = File::create(["path" => $path.$filename]);
解决方案
如果你看一下官方的 laravel API,在 File 门面上没有这样的方法 ::create 。
https://laravel.com/api/5.8/Illuminate/Filesystem/Filesystem.html
你想达到什么目的?
如果要创建新文件,请使用 ::put 方法:
int|bool put(string $path, string $contents, bool $lock = false)
查看我提供的 API 链接。或者查看官方文档
推荐阅读
- html - 缩小到下拉菜单时的导航栏问题
- reactjs - 循环内组件的单个实例上的条件类
- mysql - 如何使用mysql重写器插件?
- javascript - 这个功能性的 Javascript 示例是如何工作的?
- amazon-web-services - AWS EC2 RHEL7 实例权限问题
- laravel - 是否有任何有效的方法来获取对象的 ID 到我的创建方法
- ios - 将文档的文档 ID 添加到其自己的 Firestore 文档 - Swift 4
- sql-server - 如何在 SQL Server 2014 中将两个表中的两个日期时间累积为 VIEW?
- entity - DDD:聚合和删除
- cakephp-3.x - 如何在 cakephp 3.7 中编写正确的查询以获取列的数据并在下拉列表中显示项目列表