Skip to content
Advertisement

Show this error “Undefined index: thumbnail” when add filesystem in laravel

When I add new public directory in Filesystem Disks in filesystems.php like below

'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,
            ],
        ],
    ],

And in my Controller I want to save an image into thumbnail directory like below

$fileNameToStore = md5(time()).'.jpg';
$photoThumbnail  = ImageResize::make($productContent)
    ->resize(80, 80, function ($constraint) { $constraint->aspectRatio(); } )
    ->encode('jpg',80);

  
Storage::disk('thumbnail')->put( $fileNameToStore, $photoThumbnail);

But it shows me the error Undefined index: thumbnail. I don’t know why this error shows me. Any help appreciate

Advertisement

Answer

Change 'visibility' => 'thumbnail', to 'visibility' => 'public',

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

it can be public or private other then you can not set anything as per doc

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement