#include <CkFtp2.h>
#include <CkString.h>
#include <stdio.h>
void ChilkatSample(void)
{
CkFtp2 fdtp;
bool success;
// Any string unlocks the component for the 1st 30-days.
success = fdtp.UnlockComponent("Anything for 30-day trial");
if (success != true) {
printf("%s\n",fdtp.lastErrorText());
return;
}
fdtp.put_Hostname("ftp.chilkatsoft.com");
fdtp.put_Username("****");
fdtp.put_Password("****");
// The default data transfer mode is "Active" as opposed to "Passive".
// Connect and login to the FTP server.
success = fdtp.Connect();
if (success != true) {
printf("%s\n",fdtp.lastErrorText());
return;
}
// Change to the remote directory where the file will be uploaded.
success = fdtp.ChangeRemoteDir("junk");
if (success != true) {
printf("%s\n",fdtp.lastErrorText());
return;
}
// Upload a file.
CkString localFilename;
localFilename = "hamlet.xml";
CkString remoteFilename;
remoteFilename = "hamlet.xml";
success = fdtp.PutFile(localFilename,remoteFilename);
if (success != true) {
printf("%s\n",fdtp.lastErrorText());
return;
}
fdtp.Disconnect();
printf("File Uploaded!\n");
}