0

I am trying to access images outside the public folder in storage from the view. I can get the images in the storage/app/public folder like this

    <img src="storage/imagename.jpg" height="200" width="200">

I have an avatar folder inside storage/app/avatar , how do I get it to the view

  • Did you run `php artisan storage:link` to create a symlink between `storage/public` to `public/storage` ? – Clément Baconnier Aug 08 '20 at 07:53
  • Hi sorry my question was not clear I think. I can access public folder inside the storage/app/public and it is working. I do have a private folder named avatar inside storage/app/avatar , how do I access that one ? And yes I run php artisan storage:link – rahul vimal Aug 08 '20 at 09:04

1 Answers1

0

In your config/filesystems.php in the links attribute add the followig:

'links' => [
    ...
    public_path('avatars') => storage_path('app/avatar'),
],

Then run php artisan storage:link to create the link.

Access it like so:

<img src="avatars/1.jpg">

Or better use the asset method

<img src="{{ asset('avatars/1.jpg`) }}">
jewishmoses
  • 1,069
  • 2
  • 11
  • 16
  • Hi sorry my question was not clear I think. I can access public folder inside the storage/app/public and it is working. I do have a private folder named avatar inside storage/app/avatar , how do I access that one ? The above solution you provided is for the public folder – rahul vimal Aug 08 '20 at 09:04
  • I have updated my answer it will create a symbolic link in your public folder linking to your avatar folder so you can access it – jewishmoses Aug 08 '20 at 09:09
  • But I do not want general public access the images from the avatar folder, it should only be available for logged in users. Do the above answer you provided make avatar publicly visible ? – rahul vimal Aug 08 '20 at 09:16
  • It does not. your question was not so clear but here is a [possible solotuin](https://stackoverflow.com/a/30682456/11801683) – jewishmoses Aug 08 '20 at 09:21
  • @rahulvimal were you able to solve it , the solution provider by jewishmoses is not for s3 bucket – Kunal Rajput Nov 02 '21 at 15:10