skip to Main Content

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


  1. 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:

    $this->app->useStoragePath('/path/to/your/storage/directory/');
    

    If you want to change just the upload directory, follow this documentation

    Login or Signup to reply.
  2. The Default Filesystem Disk is defined in /config/filesystems.php. The entry looks like this:

    'default' => env('FILESYSTEM_DISK', 'local'),
    

    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:

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
        'throw' => false,
    ],
    

    Change you default filesystem disk to ‘public’ (either in the .env file or in filesystems.php). The default ‘public’ config should like to this:

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
        'throw' => false,
    ],
    

    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:

    $ php artisan storage:link
    

    Lastly, you can store your images within a /files directory by specifying it:

    $attributes[‘newfile’] = request()->file(‘newfile’)->store(‘files’);

    I hope this helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search