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

Texas's avatar

Laravel doesn't show image

I have this in the view.blade.php

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

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

In the same view I have ```use HTML;``

What I see on the screen is this:

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

on the screen I seeNO PHOTO

The pictures exists, I sow it in the folder. I'm doing something wrong, I just don't know what. I'm thinking that Laravel wants pictures to be on a specific folder... could this be the cause of the problem? Do you have any ideas?

In controller I have this:

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

The picture size is 7.673 bytes. I tried with other image, it doesn't work either. It's like something prevents all of my browsers to show pictures on localhost Has anyone encountered this problem before ? I don' know what else I should try...

0 likes
6 replies
pmall's avatar

Your images must be in the public folder, not the resource one. Then use the asset helper to get its url.

/public/img/image.png => asset('img/image.png')

3 likes
Texas's avatar

Can you please give me the entire code ? This is the first time I'm dealing with pictures in laravel. Where should I add /public/img/image.png => asset('img/image.png') ?

pmall's avatar

It is an example to show you if you want the url of /public/img/image.png you should use asset('img/image.png').

bimalshah72's avatar

Create folder 'images' in 'public' directory since it is public directory, no need to set chmod..so remove code from your controller.

and in view

{{ HTML::image('images/Folder/Subfolder/Subfolder/Photo/'.$item->Photo')}}
acdatio's avatar

I am having the same issue. On a fresh install of Laravel, nothing in the public folder with work without /public in the URL. When I run php artisan make:auth the view that is created is supposed to be perfect with the Bootstrap css, right? Well what I get is an unstyled page which only looks pretty when I use the DOM inspector to add /public so that I end up with:

<link href="http://localhost/l5/public/css/app.css" rel="stylesheet">

Where can I change the setting so that I don't have to add /public in the views each time I want to link to a file?

rafidAhsan's avatar

I able to fix the issue after 4 hours. It can be done with trim() function

see this code

<tbody>
                    @foreach ($products_user as $product)
                        <tr>
                            <td>{{$product->name}}</td>
                            <td>{{$product->phone_number}}</td>
                            <td>{{$product->url}}</td>
                            <td>
                                <img src="{{ asset('storage/images/'.trim($product->image, '"')) }}" height="100px" width="100px" alt="">
                            </td>
                            <td>{{$product->quantity}}</td>
                            <td>
                                <div class="row">
                                    <div class="col-md-6">
                                        <a href="/order_confirm/{{ $product->id }}" class="btn btn-primary btn-sm">Confirm</a>
                                    </div>
                                    <div class="col-md-6">
                                        <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="confirmDeleteModal">Delete</button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
1 like

Please or to participate in this conversation.