Laravel does not show image

I have this in view.blade.php

{{HTML::image('resources/views/Folder/Subfolder/Subfolder/Photo/'.$item->Photo)}} 

$item->Photo takes the name of the image from the database

In the same view, I have use HTML;

What I see on the screen:

 <img src="http://localhost:8000/resources/Folder/Subfolder/Subfolder/Photo/3da0d12d6d8667963392a446262b1773.jpg"> 

If I replaced {{HTML::image.... with
<img src="resources/Folder/Subfolder/Subfolder/Photo/{$item->Photo}}" alt="NO PHOTO">

I see on the screen
<img src="http://localhost:8000/resources/Folder/Subfolder/Subfolder/Photo/3da0d12d6d8667963392a446262b1773.jpg">
NO PHOTO

Images exist, I sowed it in a folder. I'm doing something wrong, I just don't know what. I think Laravel wants the photos to be in a specific folder ... could this be the cause of the problem? Do you have any ideas?

In the controller, I have this:

 $destinationPath =base_path().'\resources\Folder\Subfolder\Subfolder\Photo'; chmod($destinationPath,0777); 

Image size is 7.673 bytes. I tried with a different image, it doesn't work either. This somehow prevents all my browsers from displaying images on the local host Has anyone encountered this problem before? I do not know what else I should try ...

+6
source share
3 answers

In Laravel 5, if you plan to use your images in a shared folder, run the following answer:

Create the images folder in the public folder in Laravel 5.

Subsequently, what I'm doing is using URL::to('/') to return the base URL, after which you can add the location of the image folder, as shown in the following example:

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

OR all this inside braces

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

You must not specify write permission to the resource folder.

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

and image location folder: your_laravel_project/app/public/images

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

How to protect the image from public viewing in Laravel 5?

Note. URL::to('/') returns the base URL, and it can be used in many ways. Here you can find detailed information about this.

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

+6
source

Show the Laravel 5 image if you plan to use your images in a shared folder. To open the images folder in a shared folder in Laravel 5, simply:

 <img class="img-responsive menu-thumbnails" src="{{ asset($item->photo) }}"/> 
0
source
 {{ asset("storage/uploads/$notes->file_name")}} 

it worked for me. I had a file in the storage / application / shared folders. tried so many things. it turns out to be a little confusing, but surprisingly simple once you figure it out. I'm in laravel 5.4

0
source

All Articles