DEV Community

Cover image for Laravel 11 Display Image from Storage Folder Example
Saddam Hossain
Saddam Hossain

Posted on

3

Laravel 11 Display Image from Storage Folder Example

In this post, I will show you how to display image from storage app public folder in laravel 11 application.

Laravel provides a secure way to store images and files in the storage folder, preventing users from directly accessing files via URL. So, how can we display these images from the storage folder? Below, I’ll outline two methods you can use to display images securely from storage. Let’s explore both options so you can choose the one that works best for your needs. You Can Learn Using Switch Case in Laravel Blade (With Example)

Laravel 11 Display Image from Storage Folder Example

Solution 1:

first of all, we will create a Symbolic Link if you haven’t already, to make the public storage directory accessible from the web:

php artisan storage:link
Enter fullscreen mode Exit fullscreen mode

Now, Access the Image URL in your Blade template or controller:

You can use Laravel’s Storage facade to get the URL of the image.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class HomeController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function index()
    {
        $imageUrl = Storage::url('images/your-image.jpg');
    }
}
Enter fullscreen mode Exit fullscreen mode

Read More

Billboard image

Synthetic monitoring. Built for developers.

Join Vercel, Render, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay