function FTPExtension::connect

Same name in other branches
  1. 9 core/lib/Drupal/Core/FileTransfer/FTPExtension.php \Drupal\Core\FileTransfer\FTPExtension::connect()
  2. 8.9.x core/lib/Drupal/Core/FileTransfer/FTPExtension.php \Drupal\Core\FileTransfer\FTPExtension::connect()
  3. 11.x core/lib/Drupal/Core/FileTransfer/FTPExtension.php \Drupal\Core\FileTransfer\FTPExtension::connect()

Overrides FileTransfer::connect

File

core/lib/Drupal/Core/FileTransfer/FTPExtension.php, line 13

Class

FTPExtension
Defines a file transfer class using the PHP FTP extension.

Namespace

Drupal\Core\FileTransfer

Code

public function connect() {
    $this->connection = ftp_connect($this->hostname, $this->port);
    if (!$this->connection) {
        throw new FileTransferException("Cannot connect to FTP Server, check settings");
    }
    if (!ftp_login($this->connection, $this->username, $this->password)) {
        throw new FileTransferException("Cannot log in to FTP server. Check username and password");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.