Search code examples
phplaravelimagestorageexternal

How to display in a blade view images stored in a external storage?


I want to use an external storage to save my images and display them in a blade

I've created a custom filesystem, where my images exist (In this case, my documents folder), but when I tried to display the images in a blade, they were not displayed

My custom filesystem:

'custom' => [
    'driver' => 'local',
    'root' => 'C:/Users/my name/Documents',
    'url' => 'http://localhost/halo/public/prueba',
    'visibility' => 'public',
],

The simple blade

<img src="{{ Storage::disk('custom')->url("pantalla.png") }}">

And the route

Route::get('/prueba', function () {
    return view('prueba');
});

http://localhost/halo/public/prueba show the broken imagen icon

And the source-code show this:

<img src="C:/Users/my name/Documents/pantalla.png">

Solution

  • Using this code the image display in html view using blade file but the image get from particular project directory. suppose the image stored in uploads/admin directory and image get from uing session or we can say that middleware

    Add these code in blade file

    <img src="{{url('/uploads/admin/'.\Session::get('admin')->profile_image)}}" alt="profile image">