I have installed Laravel and began trying to write an app. I made some directories for my assets in the same directory as /app. But when I try to visit an image in my localhost for example:
I've also tried it on:
I ran into the problem when I was trying to set a background image in a view, and it kept going to 404.
This is what my app looks like under app/
->app ->assets ->commands ->config ->controllers ->database ->lang ->models ->start ->storage ->tests ->views app.txt routes.php filters.php But I get errors about requests. I have double checked that the url is correct.
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException 13 Answers
You have to put all your assets in app/public folder, and to access them from your views you can use asset() helper method.
Ex. you can retrieve assets/images/image.png in your view as following:
<img src="{{asset('assets/images/image.png')}}">
Besides put all your assets in the public folder, you can use the HTML::image() Method, and only needs an argument which is the path to the image, relative on the public folder, as well:
{{ HTML::image('imgs/picture.jpg') }} Which generates the follow HTML code:
<img src=""> The link to other elements of HTML::image() Method:
You have to do two steps:
- Put all your files (css,js,html code, etc.) into the public folder.
- Use
url({{ URL::asset('images/slides/2.jpg') }})whereimages/slides/2.jpgis path of your content.
Similarly you can call js, css etc.