ftp_login example

'connect',
                sprintf(
                    /* translators: %s: hostname:port */
                    __( 'Failed to connect to FTP Server %s' ),
                    $this->options['hostname'] . ':' . $this->options['port']
                )
            );

            return false;
        }

        if ( ! @ftp_login( $this->link, $this->options['username']$this->options['password'] ) ) {
            $this->errors->add(
                'auth',
                sprintf(
                    /* translators: %s: Username. */
                    __( 'Username/Password incorrect for %s' ),
                    $this->options['username']
                )
            );

            return false;
        }

        
class FTPExtension extends FTP implements ChmodInterface {

  /** * {@inheritdoc} */
  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");
    }
  }

  /** * {@inheritdoc} */
  protected function copyFileJailed($source$destination) {
    if (!@ftp_put($this->connection, $destination$source, FTP_BINARY)) {
      throw new FileTransferException("Cannot move @source to @destination", 0, ["@source" => $source, "@destination" => $destination]);
    }
  }
Home | Imprint | This part of the site doesn't use cookies.