Home > Mobile >  404 Get request in laravel from src file path
404 Get request in laravel from src file path

Time:01-14

Im trying to load an image from my /public/images folder in laravel. Im getting a 404 not found error. I know the image exists, and vscode even autocompletes the path for me.

here is the img tag:

<img src="/public/images/1616327614.jpg"  alt="...">

and the file path:

file path

I have also tried variations of the img src path, for example:

<img src="./public/images/1616327614.jpg"  alt="...">
<img src="./images/1616327614.jpg"  alt="...">

Any advice here would be greatly appreciated.

CodePudding user response:

Try to do something like this,

<img src="{{asset('images/1616327614.jpg')}}"  alt="...">

Or

<img src="{{public_path('images/1616327614.jpg')}}"  alt="...">

Remember to always check the documentation: https://laravel.com/docs/9.x/helpers#method-public-path

  • Related