Dhairya Lakhera
Dhairya Lakhera

Reputation: 4808

Laravel 8 image not showing

I am using Laravel 8.

Trying to show image from storage/app/subject_image/ path but it doesn't display.

Below is my code on blade

<img src="{{asset("storage/subject_image/$data->subject_image")}}" alt="">

also i have inspected element on chrome its showing right path and right image name still its not showing. below is the inpsect element screenshot

enter image description here

Upvotes: 2

Views: 12341

Answers (2)

Habib01
Habib01

Reputation: 139

The flowing 2 steps Work for me.

Step 1. Delete storage folder in public/storage Directory then

Step 2. Run this command php artisan storage:link

Upvotes: 1

Dhairya Lakhera
Dhairya Lakhera

Reputation: 4808

Important Note

storage folder is not publicly accessible from the web browser and because of that we will have to create a symbolic link

what is symbolic link ?

you can say symbolic link as alias or pointer to your path directory

Where you can configure symbolic links?

You may configure symbolic links in your filesystems configuration file that is located at path config/filesystems.php

Now lets configure symbolic link

suppose we have a image file located in storage/app/folder1/img.jpg

Now lets configure symbolic link for the above path -

Step 1: open config/filesystems.php and configure custom symbolic link

public_path('my_custom_symlink_1') => storage_path('app/folder1'),

enter image description here

Step 2 : Now run Artisan command

php artisan storage:link

Just configuring symbol link in filesystems won't work , you will have to run php artisan storage:link to create/active the symbolic link.

Step 3 : Now you can access you target file in browser using symbolic link

<img src="{{asset("my_custom_symlink_1/img.jpg")}}" >

Upvotes: 5

Related Questions