2

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

4
  • Where is your image located ? on public folder or on storage folder? Commented Sep 28, 2020 at 5:59
  • its not in public... its storage Commented Sep 28, 2020 at 6:00
  • 1
    did you run php artisan storage:link ? Commented Sep 28, 2020 at 6:00
  • No i dont know about it... its my first laravel project.. i am beginner... Commented Sep 28, 2020 at 6:02

2 Answers 2

5

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")}}" >

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.