FtpSave

Declaration: FtpSave (FTPParams: TFTPParams; SrcFile, DstFile: string; Append: boolean): integer;
The function FtpSave opens a connection to an FTP server, transfers the file SrcFile to the file DstFile on the server and disconnects from the server. Please note that the parameter DstFile must contain the full path on the FTP server. If the parameter Append is TRUE the source file is appended to the destination file. The record FTPParams has to contain the access data of the server (see TFTPParams for details).

The function returns the following error codes:

 0 ... everything is OK
-1 ... SRCFile does not exist
-2 ... cannot log in (check credentials)
-3 ... cannot read/write file (access error, file path error)
-4 ... cannot connect to host (check Host address and/or internet connection)
-5 ... the FTP server does not recognize one or more particular FTP commands
-9 ... unspecified error

Hint 1: Most FTP servers are Unix-based. Thus the path to the destination file (DstFile) normally uses slashes (/) instead of backslashes (\) to separate directories. Failing to use the correct separation character will result in an error (-3).

Hint 2: As the function FtpSave opens and closes an FTP connection for the transferred file it is rather slow and should not be used for the transfer of more than a few files. To transfer many files at once use the class TFtpConnection instead.

Hint 3: The function FtpSave uses passive mode communication to avoid problems with firewalls.