OpenFTP()

Syntax

Result = OpenFTP(#Ftp, ServerName$, User$, Password$ [, Passive [, Port]])
Description
Tries to open a connection on the specified FTP or SFTP server.

Parameters

#Ftp The number to identify the new connection. #PB_Any can be used to auto-generate this number.
ServerName$ The URL or address of the server to connect to. To connect to a SFTP server the prefix "sftp://" has to be added before the server address.
User$ The user name to authenticate on the server.
Password$ The password to authenticate on the server.
Passive (optional) Enables or disables passive mode for the connection (valid values are #True or #False). If this parameter is not specified, passive mode will be used.
Port (optional) The port to use for the connection. The default is port 21 for FTP and 22 for SFTP.

Return value

Returns nonzero if the connection was established correctly and zero if there was an error. If #PB_Any is used as the #Ftp parameter then the generated number for the connection is returned on success.

Example: For FTP

  If OpenFTP(0, "ftp.free.fr", "anonymous", "")
    Debug "Successfully connected"
  Else
    Debug "Can't connect to ftp.free.fr"
  EndIf

Example: For SFTP

  If OpenFTP(0, "sftp://test.rebex.net", "demo", "password") ; Use a public SFTP test server
    Debug "Successfully connected"
  Else
    Debug "Can't connect to test.rebex.net"
  EndIf

See Also

CloseFTP(), SetFTPDirectory(), ReceiveFTPFile(), SendFTPFile(), ExamineFTPDirectory()

Supported OS

All

<- NextFTPDirectoryEntry() - Ftp Index - ReceiveFTPFile() ->