renec112's avatar

Showing images from public folder

Hi :) I'm following the "Projectflyer" series. But i am stuck in 11 - Bulk files uploads.

I can upload multiple files, and get the files correctly stored in the database( With path and id). The images are also correctly stored in the public folder.

When i refresh the page, the img tag is correctly pointing to the same folder structure within the public folder. But it can't find the images, and it shows nothing.

I'm using laravel 5.2. Does anyone know whats happening?

Let me know if i should post some of my code.

0 likes
6 replies
frezno's avatar

@renec112 - i don't quite get it. the (uploaded) images can be found at the appropriate directory or not?

renec112's avatar

crap i've mistakenly set that comment as the best answer @frezno

Anyways, yes exactly. The images are stored as public/flyer/photos. When i inspect the broken images with chrome, i can see they are in flyer/photos.

It looks correct, somehow it doesn't work.

frezno's avatar

crap i've mistakenly set that comment as the best answer

can't you undo this, @renec112 ?

how does your img tag looks like? it's very likely that the path to your photo directory isn't set correct. or you try it with using eg url() eg

<img src="{!! url('/flyer/photos/'.$photo->pic_small) !!}" alt="{{ $photo->title }}">
renec112's avatar

It can't be undone @frezno . Or i don't know how to :D

Anyways, thank you for you input! That's crazy with your code it can actually display the image.

Inpsecting with chrome i can see your code provides a full path: <img href="http://test.app/8000 /flyers/photos/imageID.jpg"

While my code (gets path from mysql database):

            @foreach($url->photos as $photo)
                <img src="{{ $photo->path }}" alt =""/>
            @endforeach 

Just outputs <img href="flyers/photos/imageID.jpg" - and somehow that doesn't work - the result is just a dead image icon.

Have you experienced something like that before @frezno ? And thank you very much for your input. If everythng goes wrong, i could just re-write my code so i can use yours instead. I'm just wondering whats wrong here :/

frezno's avatar
frezno
Best Answer
Level 36

that's common behavior, @renec112
you need the web path not file system root path for displaying images

Please or to participate in this conversation.