Hello guys, I'm Samuel from Italy and this is my first message, I'm a noob and I'm a php developer. I need a C++ software that upload one time per day one backup on ftp. Computers are all Windows 7.
I write all the code that make a backup etc, but I cannot edit/write the right code to upload this file on our ftp. (I wanna be honest, I haven't time to study very well c++ and usually I copy/paste and edit code).
#include <CkFtp2.h>
#include <CkString.h>
#include <windows.h>
#include <stdio.h>
#include <iostream>
using std::cout;
using std::endl;
void ChilkatSample(void)
{
CkFtp2 ftp;
bool success;
// Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial");
if (success != true) {
printf("%s\n",ftp.lastErrorText());
return;
}
ftp.put_Hostname("ftp.chilkatsoft.com");
ftp.put_Username("****");
ftp.put_Password("****");
// The default data transfer mode is "Active" as opposed to "Passive".
// Connect and login to the FTP server.
success = ftp.Connect();
if (success != true) {
printf("%s\n",ftp.lastErrorText());
return;
}
// Change to the remote directory where the file will be uploaded.
success = ftp.ChangeRemoteDir("junk");
if (success != true) {
printf("%s\n",ftp.lastErrorText());
return;
}
// Upload a file.
CkString localFilename;
localFilename = "hamlet.xml";
CkString remoteFilename;
remoteFilename = "hamlet.xml";
success = ftp.PutFile(localFilename,remoteFilename);
if (success != true) {
printf("%s\n",ftp.lastErrorText());
return;
}
ftp.Disconnect();
printf("File Uploaded!\n");
}
C:\Users\utente\Desktop>g++ send.cpp -o send.exe
In file included from c:\mingw\include\ckftp2.h:21:0,
from send.cpp:1:
c:\mingw\include\CkString.h:107:24: error: 'SYSTEMTIME' has not been declared
void appendDateRfc822(SYSTEMTIME &sysTime);
^
c:\mingw\include\CkString.h:109:27: error: 'SYSTEMTIME' has not been declared
void appendDateRfc822Gmt(SYSTEMTIME &sysTime);
^
In file included from send.cpp:1:0:
c:\mingw\include\ckftp2.h:209:33: error: 'FILETIME' has not been declared
bool GetCreateTime(long index, FILETIME &outFileTime);
^
c:\mingw\include\ckftp2.h:210:37: error: 'FILETIME' has not been declared
bool GetLastAccessTime(long index, FILETIME &outFileTime);
^
c:\mingw\include\ckftp2.h:211:39: error: 'FILETIME' has not been declared
bool GetLastModifiedTime(long index, FILETIME &outFileTime);
^
c:\mingw\include\ckftp2.h:213:33: error: 'SYSTEMTIME' has not been declared
bool GetCreateTime(long index, SYSTEMTIME &outSysTime);
^
c:\mingw\include\ckftp2.h:213:7: error: 'bool CkFtp2::GetCreateTime(long int, in
t&)' cannot be overloaded
bool GetCreateTime(long index, SYSTEMTIME &outSysTime);
^
..ETC ETC ETC..
^
I'm using Windows and MinGW as a compiler.
Someone have some idea to fix this problem? or have you some code that works? (I tried this day I think 10/15 different codes but didn't works..)
It's an issue in your headers. I would recommend looking at the code of FileZilla. It's proven to work and has large support as far as ftp goes. Also, you could do a windows's equivelent of a cron job if that exists. Something that once a day uses a ftp client via cli.