How to use ftp with laravel 5?

Viewed 15366

The file Storage section of the laravel docs shows an example FTP config, but it doesn't explain how to use it. Can someone give an example of how to make laravel use an ftp connection in addition to a disk connection?

2 Answers

Configure the filesystem.php file in the config folder with the following code:

disks' => [

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

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

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
        ],

        'ftp' => [
            'driver' => 'ftp',
            'host' => 'ftp.foo.com',
            'username' => 'username',
            'password' => 'password',

            // Optional FTP Settings...
            'port' => 21,
            // 'root' => '',
            // 'passive' => true,
            // 'ssl' => true,
            // 'timeout' => 30,
        ],
    ],

then use:

Storage::disk('ftp')->get('/foo/file');
Related