The path should be https://yourdomain.com/public/imgs, assuming that you have configured the right link.
Aug 15, 2023
4
Level 1
Add Disk to filesystems.php - No Access after Upload
I have added another disk in filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
'throw' => false,
],
'img-uploads' => [
'driver' => 'local',
'root' => storage_path('app/public/content/imgs'),
'url' => env('APP_URL') . '/storage/content/imgs',
'visibility' => 'public',
'throw' => false,
],
I upload the image and want to resize it afterwards. I have already used this code when I did not create a separate disc.
$img = $request->file('image')->store('img-uploads');
$imgPath = Storage::disk('public')->path($img);
$imgManager = ImageManagerStatic::make($imgPath);
$imgManager->resize(300, 300, function ($constraint) {
$constraint->aspectRatio();
})->save($imgPath);
With this I now get the error Image source not readable.
In the folder laravel/storage/app/imgs/ the image is present, but I can't find the folder under laravel/public/storage. storage:link was executed (But before I added a disc).
Shouldn't the path actually be laravel/storage/app/public/imgs/?
Level 2
You are still using the Public folder. You can adjust this as follows
$img = $request->file('image')->store(options: 'img-uploads');
$imgPath = Storage::disk('img-uploads')->path($img);
2 likes
Please or to participate in this conversation.