Sample code for 30+ languages & platforms
DataFlex

Append to Existing File on FTP Server

See more FTP Examples

Uploads a file to the FTP server. If the remote file (on the FTP server) does not already exist, it is created. Otherwise the uploaded file is appended to the remote file.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoFtp
    String sLocalFilePath
    String sRemoteFilename
    String sTemp1

    Move False To iSuccess

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatFtp2)) To hoFtp
    If (Not(IsComObjectCreated(hoFtp))) Begin
        Send CreateComObject of hoFtp
    End

    Set ComHostname Of hoFtp To "ftp.myftpserver.com"
    Set ComUsername Of hoFtp To "myUsername"
    Set ComPassword Of hoFtp To "myPassword"

    // Connect to the FTP server.
    Get ComConnectOnly Of hoFtp To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Authenticate with the FTP server.
    Get ComLoginAfterConnectOnly Of hoFtp To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Move "/someDirectory/hamlet.xml" To sLocalFilePath
    Move "hamlet.xml" To sRemoteFilename

    // Upload to the FTP server, creating the file if it does not yet exist
    // on the FTP server, or appending to the remote file if it already exists.
    Get ComAppendFile Of hoFtp sLocalFilePath sRemoteFilename To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComDisconnect Of hoFtp To iSuccess

    Showln "Success."


End_Procedure