php - 在 laravel 中添加文件系统时显示此错误“未定义索引:缩略图”
问题描述
当我在文件系统磁盘中添加新的公共目录时,filesystems.php
如下所示
'thumbnail' => [
'driver' => 'local',
'root' => storage_path('app/public/relativeContentPath/thumbnail'),
'url' => env('APP_URL').'/storage',
'visibility' => 'thumbnail',
'permissions' => [
'file' => [
'public' => 0664,
'private' => 0600,
],
'dir' => [
'public' => 0775,
'private' => 0700,
],
],
],
在我的控制器中,我想将图像保存到thumbnail
如下目录中
$fileNameToStore = md5(time()).'.jpg';
$photoThumbnail = ImageResize::make($productContent)
->resize(80, 80, function ($constraint) { $constraint->aspectRatio(); } )
->encode('jpg',80);
Storage::disk('thumbnail')->put( $fileNameToStore, $photoThumbnail);
但它向我显示了错误Undefined index: thumbnail
。我不知道为什么这个错误告诉我。任何帮助表示赞赏
解决方案
更改'visibility' => 'thumbnail',
为 'visibility' => 'public',
https://laravel.com/docs/8.x/filesystem#file-visibility
它可以是public or private
其他的,然后你不能按照文档设置任何东西
推荐阅读
- javascript - Meteor Session setPersistent
- batch-file - 批处理文件中间的2是什么意思?
- c++ - “可变大小的对象可能未初始化” - 这是什么意思,为什么我会收到这种类型的错误?
- aws-lambda - 在 virtualenv 中安装 minizinc | Zappa 无法识别 virtualenv 之外的依赖项
- javascript - 追加后表单数据显示为空
- sql - 一半的输入没有写入 excel - exceljs 和 nodejs
- python - 熊猫和加入形状不均匀的数据框
- postgresql - 具有 M-2-M 的 2 个不同实体的类别表。我应该分开吗?[PostgreSQL]
- javascript - 正则表达式之前的任何内容,与组
- android - 从用户地图上的 4 个角检索纬度和经度