Class FTPClient() Professional
Class function of the FTPClient class
Instances of the FTPClient class are used to access an FTP server via the File Transfer Protocol. This communication protocol allows for exchanging the contents of arbitrary files between a client computer and a remote server in the Internet. A prerequisite for successfully using the FTPClient class is that Username and Password for accessing an FTP server are known. A connection to an FTP server fails without proper authentication.
// The example demonstrates the programming pattern
// for uploading or downloading files to/from
// an FTP server.
#pragma Library( "ASINet10.lib" )
PROCEDURE Main
LOCAL cFtpServer := "my_ftpserver.com"
LOCAL cUserName := "my_Username"
LOCAL cPassword := "my_password"
LOCAL oFtp, cContents
oFtp := FTPClient():new( cFtpServer, cUserName, cPassWord )
IF .NOT. oFtp:connect()
? "Unable to establish connection to:" , cFtpServer
QUIT
ENDIF
cContents := Memoread( "c:\filename.txt" )
// Uploading file contents
IF .NOT. oFtp:put( "ftp_dir\filename.txt", cContents )
? "Unable to transfer file contents"
ELSE
// Downloading file contents
? oFtp:get( "ftp_dir\filename.txt" )
ENDIF
oFtp:disconnect()
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.