Laravel: How to Change the Upload Directory and Move it to public/uploads
Learn how to customize the upload directory in Laravel by changing it from the default location to `public/uploads`. This guide provides step-by-step instructions to help you manage your file uploads more effectively.
May 25, 2024
If you've had a client using Plesk or cPanel hosting, you might have encountered the issue where these panels block symbolic links, resulting in a 403 Forbidden status.
To fix this issue, the best solution is to change Laravel's default storage/app/public
directory to public/uploads
. This way, you can avoid symbolic links altogether.
To make this change, open your config/filesystems.php
file.
'public' => [
'driver' => 'local',
'root' => public_path('uploads'),
'url' => env('APP_URL').'/uploads',
'visibility' => 'public',
'throw' => false,
],
That's it! Laravel will now use public/uploads for uploads with public visibility. No further changes are needed.