Archy
Archy

Reputation: 1

Laravel public folder path

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.

Upvotes: 0

Views: 279

Answers (2)

Giovanni Stroppa
Giovanni Stroppa

Reputation: 31

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

Upvotes: 1

user22296820
user22296820

Reputation:

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

Upvotes: 0

Related Questions