C
C
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 C Downloads
#include <C_CkFtp2.h>
void ChilkatSample(void)
{
BOOL success;
HCkFtp2 ftp;
success = FALSE;
ftp = CkFtp2_Create();
CkFtp2_putHostname(ftp,"ftp.example.com");
CkFtp2_putUsername(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 TRUE): automatically send FEAT to discover server capabilities.
CkFtp2_putAutoFeat(ftp,TRUE);
// AutoSyst (default TRUE): automatically send SYST after login to learn the server OS type.
CkFtp2_putAutoSyst(ftp,TRUE);
// AutoOptsUtf8 (default TRUE): send OPTS UTF8 ON when the FEAT response advertises UTF8.
CkFtp2_putAutoOptsUtf8(ftp,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.
CkFtp2_putAutoXcrc(ftp,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.
CkFtp2_putPassword(ftp,"myPassword");
success = CkFtp2_Connect(ftp);
if (success == FALSE) {
printf("%s\n",CkFtp2_lastErrorText(ftp));
CkFtp2_Dispose(ftp);
return;
}
printf("Connected with the configured automatic features.\n");
success = CkFtp2_Disconnect(ftp);
if (success == FALSE) {
printf("%s\n",CkFtp2_lastErrorText(ftp));
CkFtp2_Dispose(ftp);
return;
}
CkFtp2_Dispose(ftp);
}