/** * * 连接并登陆ftp服务器 * * @param string $host * @param string $username * @param string $password * @param int $port * @param int $timeout * @param bool $pasv * @return bool */ public static function connect($host, $username, $password, $port = 21, $timeout = 90, $pasv = false) { if ((self::$resource = ftp_connect($host, $port, $timeout)) === false) { throw_exception('ftp unable to connect'); } if (!self::login($username, $password)) { throw_exception('ftp unable to login'); } if ($pasv === true) { self::pasv($pasv); } return true; }