_chris's avatar

Storing/displaying sensitive images

Hi,

On my site, users are able to upload an image of their signature. I don't particularly want to store the images into the public folder for fear of other people stealing them. So, at the moment I am storing them in the storage folder. My issue with this though is that I cannot seem to access them in a webpage because the storage folder is not publicly available.

Does anyone have any solutions to this? Would it be better to save the images as base64 in the database? Or maybe there is a way of getting an image from the storage folder and passing it to a view?

0 likes
4 replies
jekinney's avatar

End of the day doesn't matter. Anybody can left click save image. Even YouTube isn't safe.

Prullenbak's avatar

Make a route for which you have to be authenticated and then read the image from the storage folder and return it as a response from there.

_chris's avatar

@Prullenbak Thanks. So if I have a route like so:

Route::get('/image', 'ImageController@getImage');

Then in the controller I have:

public function getImage()
{
    return Storage::get('myimage.gif');
}

How do I then display that within a view?

DirkZz's avatar

If you pas along the right headers with the corresponding mimetype and output the data of the image then it will render. You can look into base64 images as well.

Please or to participate in this conversation.