Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Qlic's avatar
Level 18

Display image stored inside the sotrage folder (outside public)

Hello once again,

I've read quite a few pages which kinda address the same thing as i'm after, however i can't quite seem to find the answer i'm looking for.

I store files (.pdf, .jpg etc.) in the storage directory, so a file could be stored as: storage/app/project/1/my_picture.jpg

Now i'm looking for the easiest way to display these files in my blade template, i'm assuming i'll have to use a route to access a function on the controller, but that's about as far as i'm coming.

Some examples have hunderds of code lines, whilst others use only a few, what would be the best practice of getting this to work?

0 likes
3 replies
martinbean's avatar

@Qlic You will either need to copy the uploaded files to a web-accessible folder, or have an endpoint that returns the file. I’m not sure how you’re planning on going about storing a PDF inline on a web page, though.

Qlic's avatar
Level 18

Well idealy i would like to check on extension/mimetype, if its an image it should display the thumbnail, if it's a file like .pdf it should display a little .pdf icon (font-awesome). Clicking on the file should than offer it as a download.

I know that storing this outside the public folder is harder, but it concerns "secret" content.

uxweb's avatar

@Qlic Keep using the route to access the files, just put this in your controller method:

return response()->download($fullPathToFile);

Full path can be obtained from:

$fullPathToFile = storage_path() . $filename;

Please or to participate in this conversation.