Search code examples
laravelftplaravel-storage

Laravel - connection to FTP storage server on port 22 not happening


I'm using Laravel and I want to store images via FTP to another server. I am not sure if I am doing the connection right.

The config is:

'ftp' => [
    'driver' => 'ftp',
    'host' => '11.11.11.11',
    'port' => 22,
    'username' => 'username',
    'password' => 'password',
    'root' => '/var/www'
],

To test it I created an artisan command with handle:

public function handle()
{

    $ftp = Storage::disk('ftp');
    $ftp->makeDirectory('test');

    dd($ftp);
}

And when I execute this command nothing happens. It's like I am entering an infinity loop.

How can I check if I am connecting to the FTP server? I tested out the credentials and I am able to connect with FileZilla.


Solution

  • The port 22 is for SSH/SFTP, not FTP. I guess you are using the SFTP in FileZilla. While you are trying to connect using the FTP protocol to the SFTP port in Laravel.

    If that's the case, use the SFTP in Laravel:

    'sftp' => [
        'driver' => 'sftp',
        'host' => '11.11.11.11',
        'username' => 'username',
        'password' => 'password',
        'root' => '/var/www'
    ],
    

    (no need to specify the port 22, as that's the SFTP default)