Loading An Image From Storage In Blade View (Protected)
Hi,
I need to show an image in a Blade view , however, I do not want the images to be public. Only the users who need to see a particular image can have access to it.
This is what I was doing before realizing that the images must not be accessible by anyone if the path is known/guessed:
I was storing images (which are uploaded by an admin) in storage/app/public/uploads/iotpark/warranty/
The same images were available in public/storage/... (I ran php artisan storage:link)
In my Bade view, I was getting and displaying the image using <img src="<?php echo asset("storage/uploads/iotpark/warranty/$currentFile")?>"></img>
I would now like to store my images in storage/uploads/iotpark/warranty/ instead.
What is the best way of displaying an image (which is not public) in a Blade view please? I think the ideal would be to pass the specific file from the controller to the blade view if possible.
Note: I have the Image Intervention package installed, so maybe I could use this package for this application/case?
That's what I did and it is working well, as I wanted now. I'm using a controller (the route is protected by middleware) to 'return' the image to the view.