risav's avatar
Level 1

Display image saved in storage folder

I uploaded an image on the storage folder.

On Controller:

   $chesis_no = $request->input('chesis_no');
        $filename  = $request->owner_photo->getClientOriginalName();


        $path = $request->owner_photo->storeAs('public/images/OwnerPhoto', $chesis_no.'_'.$filename);

        $owner->owner_photo = $path;

The Image is saved on the storage folder as storage/app/public/images/OwnerPhoto/(imagename).

Path saved on database as public/images/OwnerPhoto/(imagename).

How do I retrive image on img src=" "

0 likes
6 replies
Cronix's avatar
Cronix
Best Answer
Level 67

Did you link the storage dir to the public dir like the docs state? See about the "public disk" and how to set it up/use it with php artisan storage:link here: https://laravel.com/docs/5.8/filesystem

Then, the url would be /storage/images/OwnerPhoto/(imagename), or using the asset helper, asset('/storage/images/OwnerPhoto/imagename')

1 like
risav's avatar
Level 1

I am still having problem.

My storage path is public/images/OwnerPhoto/(imagename) but I need path like /storage/images/OwnerPhoto/(imagename)

Tried php artisan storage:link

elo's avatar

How are you retrieving the image?

risav's avatar
Level 1

Something like this img src="/storage/images/OwnerPhoto/imagename"

But want to make it dynamic

jlrdw's avatar

Follow the documentation examples.

Use the asset helper.

1 like
elo's avatar

Use asset helper. Wrap the path inside the asset helper like this src="asset('storage/...')"

1 like

Please or to participate in this conversation.