Skip to content Skip to sidebar Skip to footer

Laravel Doesn't Show Image

I have this in my view.blade.php: {{HTML::image('resources/views/Folder/Subfolder/Subfolder/Photo/'.$item->Photo)}} $item->Photo takes the image name from the database. In t

Solution 1:

In Laravel 5 if you plan to have your images available in public folder, follow this answer:

Create images folder under public folder in Laravel 5.

Afterward what I do, I use URL::to('/') to return base URL, then you can added your images folder location like following example:

<img src="{{ URL::to('/') }}/images/{{ $item->Photo }}" alt="{{ $item->Title }}" />

OR all of it inside the braces

<img src="{{ URL::to('/images/' . $item->Photo) }}" alt="{{ $item->Title }}" />

You should not give write permission to resources folder.

{{ URL::to('/images') }} generate http://localhost/images in local host environment.

and the folder of images location is: your_laravel_project/app/public/images

If you plan to protect your images from public view, so only authenticated user can see the images, then follow this link:

How to protect image from public view in Laravel 5?

Note:URL::to('/') returns base URL and it can be used different ways. Here you can find in depth info about it.

Reference: http://laravel.com/api/5.1/Illuminate/Contracts/Routing/UrlGenerator.html#method_to

Solution 2:

{{ asset("storage/uploads/$notes->file_name")}}

this worked for me. i had file in uploads of storage/app/public folder. tried so many things. turns out its little confusing but awesomely simple once u figure it out. i am in laravel 5.4

Solution 3:

Show image Laravel 5 if you plan to have your images available in public folder. To display images folder under public folder in Laravel 5 simple:

<img class="img-responsive menu-thumbnails" src="{{ asset($item->photo) }}"/>

Post a Comment for "Laravel Doesn't Show Image"