Reputation: 5355
I am using Laravel Framework 8.62.0
and save uploaded images like the following:
$contents = file_get_contents($imgUrl);
// $file_name = basename($url_upper);
$file_name = strtolower(substr($imgUrl, strrpos($imgUrl, '/') + 1));
$strg = Storage::disk('public_collectible_img')->put($file_name, $contents);
My public_collectible_img
-driver looks like the following:
'public_collectible_img' => [
'driver' => 'local',
'root' => storage_path('app/public/collectibles_img'),
'url' => env('APP_URL').'/collectible/image',
'visibility' => 'public',
],
When I try to open the following url localy I get a 404
-error.
http://localhost/my_project/public/collectible/image/1.jpg
The image exists in the folder:
How to access the image and what is the correct url?
I appreciate your replies!
Upvotes: 0
Views: 1525
Reputation: 4166
You have to create the a symbolic link between "storage" and "public" folder
To make these files accessible from the web, you should create a symbolic link from public/storage to storage/app/public.
Run the following artisan code:
php artisan storage:link
Reference: https://laravel.com/docs/8.x/filesystem#the-public-disk
Upvotes: 1