Hujjat's avatar
Level 10

How to change default upload file directory

Hi,

By default, when we upload file with laravel 5.3, it uploads in storage/app directory. How can I change the default directory for upload file to public directory?

Thank's

0 likes
5 replies
Hujjat's avatar
Level 10

@bobbybouwmann I have changed, but still not uploading in the public directory

'''

    'disks' => [

      'local' => [
          'driver' => 'local',
            'root' => storage_path('public/avatar'),
     ],

        'public' => [
         'driver' => 'local',
         'root' => storage_path('app/public'),
         'visibility' => 'public',
        ],

        's3' => [
         'driver' => 's3',
         'key' => 'your-key',
         'secret' => 'your-secret',
         'region' => 'your-region',
            'bucket' => 'your-bucket',
     ],

 ],


'''
Hujjat's avatar
Level 10

@bobbybouwmann as regular way,

in the controller store function

'''

    $request->file('user_avatar')->store('avatars');

'''

bobbybouwmann's avatar
Level 88

What do you have in filled in your config under the key filesystems.default?

Additionally you can pass an argument to select the disk you want to use

$request->file('user_avatar')->store('avatars', 'my-disk');

Please or to participate in this conversation.