I have stored my images in following storage directory:
storage\app\images\
I now need to make this directory publicly accessible.
I stored and created the 'image disk' as follows:
in my controller:
Storage::makeDirectory('images');
Storage::disk('images')->put($imagename, $image);
Then in my config/filesystems i created another disk:
'images' => [
'driver' => 'local',
'root' => storage_path('app/images'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
],
there is already a symlink to the storage/app/public. How do I now make the new directory public.
I tried accessing the image like this:
<img src="{{url('storage/app/images/image.jpeg')}}">
It gave error message image not found.
I also tried to manually create a link:
ln -s storage/app/images public/storage/app/images
EDIT:
Please note that for reason beyond this question, I cannot store my images in:
storage/app/public
The only directory available to me is:
storage\app\images\
So the issue is how to make the above directory publicly accessible.
In answer to @skdishansachin my .env has this entry:
FILESYSTEM_DRIVER=local
and in answer to @Hello There
this is the error;
404 Not Found
https://testSite/storage/app/images/image.jpeg
I have stored my images in following storage directory:
storage\app\images\
I now need to make this directory publicly accessible.
I stored and created the 'image disk' as follows:
in my controller:
Storage::makeDirectory('images');
Storage::disk('images')->put($imagename, $image);
Then in my config/filesystems i created another disk:
'images' => [
'driver' => 'local',
'root' => storage_path('app/images'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
],
there is already a symlink to the storage/app/public. How do I now make the new directory public.
I tried accessing the image like this:
<img src="{{url('storage/app/images/image.jpeg')}}">
It gave error message image not found.
I also tried to manually create a link:
ln -s storage/app/images public/storage/app/images
EDIT:
Please note that for reason beyond this question, I cannot store my images in:
storage/app/public
The only directory available to me is:
storage\app\images\
So the issue is how to make the above directory publicly accessible.
In answer to @skdishansachin my .env has this entry:
FILESYSTEM_DRIVER=local
and in answer to @Hello There
this is the error;
404 Not Found
https://testSite/storage/app/images/image.jpeg
Sorry for the delay in my response. I am using Laravel 11 in a project, but from what I remember and have seen in the documentation, the way to register disks for file uploads in a Laravel project has not changed.
1. Create the Laravel Disk
In the config/filesystems.php
file, create the disk you want:
In this case, I am creating the FAQs disk, but as you requested, it is outside the "storage/app/public" folder. In this case, it will be in "storage/app/faqs".
return [
'disks' => [
'faqs' => [
'driver' => 'local',
'root' => storage_path('app/faqs'),
'url' => env('APP_URL') . '/faqs',
'visibility' => 'public',
],
],
];
2. Add the Symbolic Link at the End of the config/filesystems.php
Finally, you need to establish the symbolic link so that Laravel registers it when the command is executed.
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('faqs') => storage_path('app/faqs'), // Add yours here, important to establish the same file hierarchy as before
],
3. Execute the Laravel Command
Now, execute the following command:
php artisan storage:link
This should generate the symbolic link to the new disk created in "storage". In this case, we have created a disk at the path storage/app/faqs
.