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

hidayat3676's avatar

how to create path to assets folder

i have the following hierarchy in my assets folder

public>> assets >> frontend >> images>> 1.jpg 
my code is

<img src="{{asset('frontend/images/players/1.jpg')}}" alt="location-team">

but i am getting 404 error  whats wrong with this 
0 likes
5 replies
rin4ik's avatar
rin4ik
Best Answer
Level 50

if this is the folder structure public>> assets >> frontend >> images>> 1.jpg

<img src="{{asset('assets/frontend/images/1.jpg')}}" alt="location-team">

or if the folder structure public>> assets >> frontend >> images>> players>> 1.jpg

<img src="{{asset('assets/frontend/images/players/1.jpg')}}" alt="location-team">
3 likes
nonwip's avatar

@rin4ik just gave you correct answer...

asset() helper looks at public folder only. So you can grab an asset by calling asset('css/app.css') for example.

In your case, you created an assets directory and inside you nested a couple more directories... so you clearly must specify full path to the asset.

If you feel like it's a bit too much to write, you could always create your own little helper function that will look into public/assets/frontend/ for example.

hidayat3676's avatar

it,s work now but next problem is below


style="background-image:http://127.0.0.1:8000/assets/frontend/images/players/1.jpg

this doesn't work

nonwip's avatar

You did not correctly specify that path...

style="background-image: url('{{ asset('assets/frontend/images/players/1.png') }}');"

rin4ik's avatar
style="background-image: url('/assets/frontend/images/players/1.png')"
1 like

Please or to participate in this conversation.