首页 > 解决方案 > 在 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。我不知道为什么这个错误告诉我。任何帮助表示赞赏

标签: phplaravelstorage

解决方案


更改'visibility' => 'thumbnail', 'visibility' => 'public',

https://laravel.com/docs/8.x/filesystem#file-visibility

它可以是public or private其他的,然后你不能按照文档设置任何东西


推荐阅读