Learn
composer require league/flysystem-sftp-v3
'disks' => [
// ... other disks here
'sftp' => [
'driver' => 'sftp',
'host' => env('SFTP_HOST'),
'port' => env('SFTP_PORT', 22),
'username' => env('SFTP_USERNAME'),
'password' => env('SFTP_PASSWORD'),
'root' => env('SFTP_ROOT'),
'permPublic' => 0755,
'directoryPerm' => 0755,
'visibility' => 'public',
'timeout' => 30,
],
]
SFTP_HOST=eu-central-1.sftpcloud.io # Replace with the host of your SFTP server
SFTP_USERNAME="sftpcloud-user" # The name of your SFTP user
SFTP_PASSWORD="sftpcloud-pass" # The password of your SFTP user
SFTP_PORT=22 # If your server is not using the default port, replace it
SFTP_ROOT="/" # Root directory on the SFTP server where the files will be stored
// List all the files
Storage::disk('sftp')->list();
// Delete a directory
Storage::disk('sftp')->deleteDirectory('my-directory');
// Write to a file
Storage::disk('sftp')->put('example.txt', 'My content');
// Create a directory
Storage::disk('sftp')->makeDirectory('my-directory');