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 
1

3 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')}}">

5

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:

  1. Put all your files (css,js,html code, etc.) into the public folder.
  2. Use url({{ URL::asset('images/slides/2.jpg') }}) where images/slides/2.jpg is path of your content.

Similarly you can call js, css etc.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy