#Unable to display images/css from the public folder.

14 messages · Page 1 of 1 (latest)

willow bone
#

Hello, I am trying to access images and css files located in the public directory but I keep running into a 404 saying that the files don't exist.

<img src="{{ asset('/img/tampa-4811962.jpg')}}" alt="Tampa" width="500" height="600">
<link href="{{ URL::asset('/public/css/app.css') }}" type="text/css" rel="stylesheet"/>

my file paths for both the images and css are the following:
public/css/app.css
public/img/images

I've tried using different methods of calling the actual files, like replacing asset() and doing css/app.css instead of appending public and nothing has worked. I'm starting to think its an issue with my laravel installation but I don't know what it could be.

Any help is greatly appreciated.

EDIT:
To anyone reading this, heres an update of what I've tried so far after making this post:

  • Converted local css to scss and built a vite instance. my css is now in a build/assets folder but that shouldn't change much considering it still doesn't work.

  • Running npm run dev or storage links

  • Clearing caches

rugged mural
#

maybe try php artisan storage:link

#

also npm run dev will build the assets again if you haven't run it since you added them..

willow bone
#

yeah i ran the artisan storage link and it created the storage folder

rugged mural
#

running npm run dev will rebuild your assets too

willow bone
#

yeah i've been running that for scss files

#

still a 404

rugged mural
#

hmm in my app.blade.php on one of my projects i have this for icons (they're directly in the public folder - principle the same) maybe you only need this syntax instead of the rest...but i can't be sure, it's been a while 😦

    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
    <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}">
#

especially the last line, i don't think you need URL there etc..

willow bone
#

Im trying it differently by using vite to build the files and now have this

willow bone
#

im currently trying this <link href="{{ Vite::asset('app.css') }}" type="text/css" rel="stylesheet"/> but it also doesnt work

#

very confused

willow bone
#

solved using vite