My All Uploading Files Are saved in Project/Storage/App
But I want to save in cdn.myproject.com/files/
How i can do it please guide me
Thank you
My All Uploading Files Are saved in Project/Storage/App
But I want to save in cdn.myproject.com/files/
How i can do it please guide me
Thank you
2
Answers
Do you want to change your entire storage path, or just the uploaded path?
To change storage/ path: in
app/Providers/AppServiceProvider
register()
method, add the following line:If you want to change just the upload directory, follow this documentation
The Default Filesystem Disk is defined in /config/filesystems.php. The entry looks like this:
You may, or may not, have an entry in the .env file for FILESYSTEM_DISK. If not, the default value in this example is set to ‘local’. ‘local’ is defined further down the filesystems.php file and looks like this:
Change you default filesystem disk to ‘public’ (either in the .env file or in filesystems.php). The default ‘public’ config should like to this:
As you see above Laravel wants to store your files within the storage path. Since this is a "non-public" directory, you have have to use ‘php artisan’ to create a symbolic link from this location to a location in the public directory. Use this command:
Lastly, you can store your images within a /files directory by specifying it:
$attributes[‘newfile’] = request()->file(‘newfile’)->store(‘files’);
I hope this helps.