Drewlim7
6 months ago
852
8
Laravel

How to retrieve image from storage's custom directory.

Posted 6 months ago by Drewlim7

Hi, I had searched some of the tutorial for retrieving image from storage. Some suggested using routes.php to handler the request. Some just accessed from blade using asset or url method. I am still confusing on how to retrieve image through storage's custom directory. I have a custom local dis and I did use symbolic:link, but still couldn't manage to retrieve image and populate all over in a blade file. All my images are stored into storage/app/campaign_image/{id}/imageName.jpg. Also, how am I going to restrict user to access the directory? Sorry if someone has asked similar question, but i still couldn't understand those answer.

This is my filesystem.php

'campaign' => [
     'driver' => 'local',
     'root' => storage_path('app/campaign_image'),
             'permissions' => [
                 'file' => [
                     'public' => 0664,
                     'private' => 0600,
                 ],
                 'dir' => [
                     'public' => 0775,
                     'private' => 0700,
                 ],
             ],
        ],

Please sign in or create an account to participate in this conversation.