Sample code for 30+ languages & platforms
DataFlex

FTP Automatic Post-Connect Commands

See more FTP Examples

Demonstrates the AutoFeat, AutoSyst, AutoOptsUtf8, and AutoXcrc properties, which control commands Chilkat issues automatically around connecting and transferring.

Background: Chilkat normally probes and adapts to a server on its own: AutoFeat discovers capabilities with FEAT, AutoSyst learns the OS type to parse legacy listings, and AutoOptsUtf8 enables UTF-8 filenames when the server advertises it. These are on by default and rarely worth changing. AutoXcrc is the exception worth enabling deliberately — it verifies each upload with the server's XCRC checksum, catching corruption automatically where supported.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoFtp
    String sTemp1

    Move False To iSuccess

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

    Set ComHostname Of hoFtp To "ftp.example.com"
    Set ComUsername Of hoFtp To "myFtpLogin"

    //  These auto-* properties control commands Chilkat sends automatically after connecting.  They
    //  are on/off by default as noted, and are rarely changed.

    //  AutoFeat (default True): automatically send FEAT to discover server capabilities.
    Set ComAutoFeat Of hoFtp To True

    //  AutoSyst (default True): automatically send SYST after login to learn the server OS type.
    Set ComAutoSyst Of hoFtp To True

    //  AutoOptsUtf8 (default True): send OPTS UTF8 ON when the FEAT response advertises UTF8.
    Set ComAutoOptsUtf8 Of hoFtp To True

    //  AutoXcrc (default False): request an XCRC checksum after each upload and treat a mismatch as
    //  a failure, giving automatic post-upload verification where the server supports XCRC.
    Set ComAutoXcrc Of hoFtp To True

    //  Normally you would not hard-code the password in source.  You should instead obtain it
    //  from an interactive prompt, environment variable, or a secrets vault.
    Set ComPassword Of hoFtp To "myPassword"

    Get ComConnect Of hoFtp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Connected with the configured automatic features."

    Get ComDisconnect Of hoFtp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure