Laravel, not displayed image from public folder

10,981

Solution 1

Try this:

<img src="{{ asset('front/images/index/logo.jpg'); }}">

You don't need to use public prefix with asset().

Solution 2

Laravel has some rewrite rules to rewrite you url path. The static files may not be accessed due to following reasons: 1. Check the permission of your folders, "chmod -R 777 folder" in Linux or authenticate the permission to anyone for the folder in Windows, then try again. 2. Check the web server configure if it restrcits the folder to be accessed. 3. Check your route if there is any route/resource/route::group has the same name with the folder.

By the way, you can put your static files in another folder which is out of the base_path() in Laravel, then set a alias in the web server to let it be accessed. In case, this method makes the structure more clear.

Solution 3

Try to use this, If your image is in public folder

<img src="{{url('images/banner1.jpg')}}" >
Share:
10,981
Katrin_cage
Author by

Katrin_cage

Updated on December 02, 2022

Comments

  • Katrin_cage
    Katrin_cage 11 months

    I have problem with displaing images from public directory:

    <img src="{{asset('public/front/images')}}/index/logo.jpg">
    

    Image looks like this. enter image description here

    from another folders images are displaed correctly

    <img src="{{url('/')}}/images/banner1.jpg" >
    
    • Parth Vora
      Parth Vora over 6 years
      Inspect the image using browser debugger and check what is path there?
    • Soniya Basireddy
      Soniya Basireddy over 6 years
      may be path missing check it out once...and follow the comment of @ParthVora
    • Afshan Shujat
      Afshan Shujat over 6 years
      Use public_path() to get path upto public
    • Jithin
      Jithin over 5 years
      anyone on this solution?