Laravel
How to Save Files as Public Instead of Private in Laravel Storage
Thank you for your continued support.
This article contains advertisements that help fund our operations.
A summary of how to save files as public instead of private in Laravel storage
PR
How to Save as Public (Conclusion)
$image = $request->file('image');
$image_url = Storage::disk('public')->put('image', $image, 'public'); // Specify 'public' in the disk
Alternatively:
$path = $request->file('image')->store('image', 'public');
By specifying 'public'
like this, the file will be saved in:
storage/app/public
This allows you to use symbolic links and other features.
Where Is the Configuration Defined?
In config/filesystems.php
, there is a disks
section.
Checking the public
configuration reveals that files are stored in app/public
.
If no specific disk is specified, the local
setting is used by default, which saves files in app/private
.
I hope this helps someone!
Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!