PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkFtp2.pb"
Procedure ChilkatExample()
success.i = 0
ftp.i = CkFtp2::ckCreate()
If ftp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkFtp2::setCkHostname(ftp, "ftp.example.com")
CkFtp2::setCkUsername(ftp, "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 1): automatically send FEAT to discover server capabilities.
CkFtp2::setCkAutoFeat(ftp, 1)
; AutoSyst (default 1): automatically send SYST after login to learn the server OS type.
CkFtp2::setCkAutoSyst(ftp, 1)
; AutoOptsUtf8 (default 1): send OPTS UTF8 ON when the FEAT response advertises UTF8.
CkFtp2::setCkAutoOptsUtf8(ftp, 1)
; AutoXcrc (default 0): request an XCRC checksum after each upload and treat a mismatch as
; a failure, giving automatic post-upload verification where the server supports XCRC.
CkFtp2::setCkAutoXcrc(ftp, 1)
; 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.
CkFtp2::setCkPassword(ftp, "myPassword")
success = CkFtp2::ckConnect(ftp)
If success = 0
Debug CkFtp2::ckLastErrorText(ftp)
CkFtp2::ckDispose(ftp)
ProcedureReturn
EndIf
Debug "Connected with the configured automatic features."
success = CkFtp2::ckDisconnect(ftp)
If success = 0
Debug CkFtp2::ckLastErrorText(ftp)
CkFtp2::ckDispose(ftp)
ProcedureReturn
EndIf
CkFtp2::ckDispose(ftp)
ProcedureReturn
EndProcedure