ftp_connection::connect

Description

Called by ftp_connection to open a new connection.

Syntax

void ftp_connection::connect (string $ftp_server[, int $ftp_port[, string $ftp_user[, string $ftp_pass]]])



Parameter $ftp_server

Expected type: String
Description: The server to connect to



Parameter $ftp_port

Expected type: Integer
Description: Which port to connect to. Default is 21 (standard FTP port).



Parameter $ftp_user

Expected type: String
Description: The username to connect with. Default is 'anonymous'.



Parameter $ftp_pass

Expected type: String
Description: The password to connect with. Default is '[email protected]' (anonymous FTP generally requires your email address for the password)


Notes

  • Will not work if fsockopen or fwrite are disabled
  • Checks for appropriate status code after each step
  • Uses ssl if "ftps://" is detected in the server name
  • Sets a 'bad_server' error and returns (to the calling function) if the connection couldn't be opened
  • Sets a 'bad_response' error and returns if it does not receive a welcome message from the server
  • Sets a 'bad_user' error and returns if it does not receive a message stating that the username is ok and requires a password
  • Sets a 'bad_password' error and returns if the password wasn't valid
Advertisement: