skip to Main Content

I am using laravel 10, and have images inside /public/images , when i try yo use asset or public_path(), i get a duplicate prepended to the url like so

Using public_path();
file_get_contents(/var/www/soccia/var/www/soccia/public): Failed to open stream: No such file or directory.

Using asset();
file_get_contents(/var/www/socciahttp://158.68.112.29/images/1705750845_profile.png): Failed to open stream: No such file or directory

database contains paths like this (/images/img.png)

i did change asset_url in app.php

‘asset_url’ => env(‘ASSET_URL’, null),

but doesn’t fix the problem.

2

Answers


  1. Can you try public_path('images'); instead of public_path();?

    Login or Signup to reply.
  2. You can try url($filepath)

    For example, if a register to a filepath on your database is images/1705750845_profile.png and you need the path to this image in your public folder, you can use url('images/1705750845_profile.png'). The result will be (on a local development env):

    http://localhost/images/1705750845_profile.png
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search