Search code examples
phplaravelimagestorage

Laravel : Problem showing image from the storage folder


I'm having a problem viewing image fron the storage folder, here are the codes:

->editColumn('image_path', function ($submission) {
                $imgUrl = asset('storage' . str_replace('public', '', $submission->image_path));
                return "<img src=\"{$imgUrl}\" alt=\"Gambar Barang\" width=\"250\" />";
            })

I tried php artisan storage:link it says the link already exists, last time the image was showing but after i deleted my project folder and pasted a new one the images doesn't showing.


Solution

  • Laravel generate cache version of that storage link..

    Step 1

    Delete the storage folder created by storage link command inside a public folder on your root directory

    Step 2

    Then execute these commands

    php artisan optimize:clear
    
    php artisan storage:link
    

    The output on terminal should be

    The [public/storage] link has been connected to [storage/app/public].