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

mathewp's avatar

Access images from storage/app/public folder without creating a link

hi all, i am using a shared hosting. How can I retrieve an image from storage/app/public folder without creating a link with public folder.

0 likes
2 replies
automica's avatar

@mathewp

1 - if you aren't able to create a symlink, its very likely if you ask your ISP they can do it for you.

2 - if they cant you could just upload to public/images instead of storage/public/images

3 - if you don't want to do that, and images are small:

from this stackoverflow:

https://stackoverflow.com/questions/30191330/laravel-5-how-to-access-image-uploaded-in-storage-within-view

If, for any reason, your can't create symbolic links (maybe you're on shared hosting, etc.) or you want to protect some files behind some access control logic, there is the alternative of having a special route that reads and serves the image. For example a simple closure route like this:

Route::get('storage/{filename}', function ($filename)
{
    $path = storage_path('public/' . $filename);

    if (!File::exists($path)) {
        abort(404);
    }

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    $response->header("Content-Type", $type);

    return $response;
});

The last option has a performance hit as you are serving your images through Laravel rather than directly from the server.

If you cant symlink, my preferred method would be option 2.

mathewp's avatar

I want to display the image in my blade file. Can i use it as a general function in my project

Please or to participate in this conversation.