File not found at path in laravel 7x

13,017

Your file is under storage/public folder but you trying to access it from storage folder.

Check your error path C:\xampp\htdocs\admin\storage/123.jpg

Change

$path = storage_path()."/".$filename;

to

$path = storage_path('public/' . $filename);
Share:
13,017

Related videos on Youtube

sajadsholi
Author by

sajadsholi

Updated on June 04, 2022

Comments

  • sajadsholi
    sajadsholi almost 2 years

    I have an image at storage/public and I want access that with Storage library but i get error "File not found at path"

    I search a lot in the internet and I don't get any solution for my problem so please help me.

    my code :

    $filename = '123.jpg';
    $path = storage_path()."/".$filename;
    Storage::disk('local')->get($path);
    dd($contents);
    

    the error :

    Illuminate\Contracts\Filesystem\FileNotFoundException
    C:\xampp\htdocs\admin\storage/123.jpg
    

    the things i tried :

    php artisan storage:link
    

    the filesystem.php

    <?php
    
    return [
        'default' => env('FILESYSTEM_DRIVER', 'local'),
    
        'cloud' => env('FILESYSTEM_CLOUD', 's3'),
    
        'disks' => [
    
            'local' => [
                'driver' => 'local',
                'root' => storage_path('app'),
                'permissions' => [
                    'file' => [
                        'public' => 0664,
                        'private' => 0600,
                    ],
                    'dir' => [
                        'public' => 0775,
                        'private' => 0700,
                    ],
                ]
            ],
    
            'public' => [
                'driver' => 'local',
                'root' => storage_path('app/public'),
                'url' => env('APP_URL') . '/storage',
                'visibility' => 'public',
            ],
    
            's3' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'url' => env('AWS_URL'),
            ],
    
        ],
    
        'links' => [
            public_path('storage') => storage_path('app/public'),
        ],
    
    ];