kwestionable
kwestionable

Reputation: 496

ERROR 404 for js and css files, Laravel 5.8

I get error 404 when trying to get the path of my css and js files. Any help will be appreciated, I'm using Laravel 5.8

<link href="{{asset('./public/css/bootstrap-datepicker.css')}}" rel="stylesheet">

<script src="{{asset('./public/js/jquery.js')}}"></script>

<script src="{{asset('./public/js/bootstrap-datepicker.js')}}"></script>

Here's my directory

enter image description here

Question 2: How can I access the files from node_modules? I also get error 404

This is my code for accessing node_modules files:

<link href="{{asset('dist/css/datepicker.min.css')}}" rel="stylesheet" type="text/css">
<script src="{{asset('dist/js/datepicker.min.js')}}"></script>

<!-- Include English language -->
<script src="{{asset('dist/js/i18n/datepicker.en.js')}}"></script>

enter image description here

Upvotes: 0

Views: 1040

Answers (4)

Udhav Sarvaiya
Udhav Sarvaiya

Reputation: 10111

For CSS:

<link href="{{ asset('css/bootstrap-datepicker.css') }}" rel="stylesheet" type="text/css" >

Make your directory structure is like this for CSS: /public/css/bootstrap-datepicker.css


For Javascript:

<script type="text/javascript" src="{{ URL::asset('js/jquery.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('js/bootstrap-datepicker.js') }}"></script>

Make your directory structure is like this for JS:

/public/js/jquery.js
/public/js/bootstrap-datepicker.js

Upvotes: 0

Puneet Sharma
Puneet Sharma

Reputation: 305

Please try this and replace

<link href="{{asset('./public/css/bootstrap-datepicker.css')}}" rel="stylesheet">

to

<link href="{{URL::asset('css/bootstrap-datepicker.css')}}" rel="stylesheet">

The asset will get the path of the public folder.

Hope this will work.

Upvotes: 0

Paul Carlo Tordecilla
Paul Carlo Tordecilla

Reputation: 60

<link href="{{asset('css/bootstrap-datepicker.css')}}" rel="stylesheet">

<script src="{{asset('js/jquery.js')}}"></script>

<script src="{{asset('js/bootstrap-datepicker.js')}}"></script> 

this the right answer... :D

Upvotes: 1

butter
butter

Reputation: 13

Try removing the './' and just do

<link href="{{asset('public/css/bootstrap-datepicker.css')}}" rel="stylesheet">

Upvotes: 1

Related Questions