Visualizzazione dei risultati da 1 a 1 su 1

Visualizzazione discussione

  1. #1

    C++ problema upload Ftp

    Salve ragazzi, preannuncio che sono veramente 0 in c++, sviluppo solitamente in php che è ''leggermente'' più semplice. Il tempo che ho disposizione non mi permette di imparare da zero ad utilizzare questo linguaggio perciò mi sto un pò arrangiando un pò scrivendo e un pò copiando codici già esistenti.

    Sto sviluppando un software che deve girare in background su alcune macchine windows, questo codice ad un certo momento della giornata (la sera) deve eseguire un backup e caricarlo via ftp su un server.

    Mi sono bloccato sul caricamento via upload ftp. Ho provato diversi codici ma ho sempre problemi nella compilazione. Librerie mancanti.. (che poi divento matto a cercarle ma una volta messe poi mi danno altri errori) e errori di ogni sorta. Ora avrei questo codice trovato su internet:

    codice:
    #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");
        }
    Questo codice per quanto abbia cercato di trovare soluzione a correggerlo mi da questi errore:

    codice:
    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);
           ^
    c:\mingw\include\ckftp2.h:209:7: error: with 'bool CkFtp2::GetCreateTime(long in
    t, int&)'
      bool GetCreateTime(long index, FILETIME &outFileTime);
           ^
    c:\mingw\include\ckftp2.h:214:37: error: 'SYSTEMTIME' has not been declared
      bool GetLastAccessTime(long index, SYSTEMTIME &outSysTime);
                                         ^
    c:\mingw\include\ckftp2.h:214:7: error: 'bool CkFtp2::GetLastAccessTime(long int
    , int&)' cannot be overloaded
      bool GetLastAccessTime(long index, SYSTEMTIME &outSysTime);
           ^
    c:\mingw\include\ckftp2.h:210:7: error: with 'bool CkFtp2::GetLastAccessTime(lon
    g int, int&)'
      bool GetLastAccessTime(long index, FILETIME &outFileTime);
           ^
    c:\mingw\include\ckftp2.h:215:39: error: 'SYSTEMTIME' has not been declared
      bool GetLastModifiedTime(long index, SYSTEMTIME &outSysTime);
                                           ^
    c:\mingw\include\ckftp2.h:215:7: error: 'bool CkFtp2::GetLastModifiedTime(long i
    nt, int&)' cannot be overloaded
      bool GetLastModifiedTime(long index, SYSTEMTIME &outSysTime);
           ^
    c:\mingw\include\ckftp2.h:211:7: error: with 'bool CkFtp2::GetLastModifiedTime(l
    ong int, int&)'
      bool GetLastModifiedTime(long index, FILETIME &outFileTime);
           ^
    c:\mingw\include\ckftp2.h:290:2: error: '__int64' does not name a type
      __int64 get_ProgressMonSize64(void);
      ^
    c:\mingw\include\ckftp2.h:291:29: error: '__int64' has not been declared
      void put_ProgressMonSize64(__int64 newVal);
                                 ^
    c:\mingw\include\ckftp2.h:328:2: error: '__int64' does not name a type
      __int64 get_AsyncBytesReceived64(void);
      ^
    c:\mingw\include\ckftp2.h:329:2: error: '__int64' does not name a type
      __int64 get_AsyncBytesSent64(void);
      ^
    c:\mingw\include\ckftp2.h:384:49: error: 'SYSTEMTIME' has not been declared
      bool GetCreateTimeByName(const char *filename, SYSTEMTIME &outSysTime);
                                                     ^
    c:\mingw\include\ckftp2.h:385:53: error: 'SYSTEMTIME' has not been declared
      bool GetLastAccessTimeByName(const char *filename, SYSTEMTIME &outSysTime);
                                                         ^
    c:\mingw\include\ckftp2.h:386:55: error: 'SYSTEMTIME' has not been declared
      bool GetLastModifiedTimeByName(const char *filename, SYSTEMTIME &outSysTime);
                                                           ^
    c:\mingw\include\ckftp2.h:392:21: error: 'SYSTEMTIME' has not been declared
      void SetOldestDate(SYSTEMTIME &oldestDateTime);
                         ^
    c:\mingw\include\ckftp2.h:404:29: error: 'SYSTEMTIME' has not been declared
      bool SetRemoteFileDateTime(SYSTEMTIME &dateTime, const char *remoteFilename);
                                 ^
    c:\mingw\include\ckftp2.h:492:2: error: '__int64' does not name a type
      __int64 GetSizeByName64(const char *filename);
      ^
    c:\mingw\include\ckftp2.h:495:2: error: '__int64' does not name a type
      __int64 GetSize64(int index);
      ^
    
    C:\Users\utente\Desktop>#include <CkFtp2.h>
    The syntax of the command is incorrect.
    
    C:\Users\utente\Desktop>#include <CkString.h>
    The syntax of the command is incorrect.
    
    C:\Users\utente\Desktop>#include <windows.h>
    The syntax of the command is incorrect.
    
    C:\Users\utente\Desktop>#include <stdio.h>
    The syntax of the command is incorrect.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>#include <iostream>
    The syntax of the command is incorrect.
    C:\Users\utente\Desktop>using std::cout;
    'using' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>using std::endl;
    'using' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>void ChilkatSample(void)
    'void' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    {
    '{' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    CkFtp2 ftp;
    'CkFtp2' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    bool success;
    'bool' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    //  Any string unlocks the component for the 1st 30-
    days.
    '//' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    success = ftp.UnlockComponent("Anything for 30-day t
    rial");
    'success' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    if (success != true) {
    != was unexpected at this time.
    
    C:\Users\utente\Desktop>        printf("%s\n",ftp.lastErrorText());
    'printf' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>        return;
    'return' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    }
    '}' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    ftp.put_Hostname("ftp.chilkatsoft.com");
    'ftp.put_Hostname' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    ftp.put_Username("****");
    'ftp.put_Username' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    ftp.put_Password("****");
    'ftp.put_Password' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    //  The default data transfer mode is "Active" as op
    posed to "Passive".
    '//' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    //  Connect and login to the FTP server.
    '//' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    success = ftp.Connect();
    'success' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    if (success != true) {
    != was unexpected at this time.
    
    C:\Users\utente\Desktop>        printf("%s\n",ftp.lastErrorText());
    'printf' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>        return;
    'return' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    }
    '}' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    //  Change to the remote directory where the file wi
    ll be uploaded.
    '//' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    success = ftp.ChangeRemoteDir("junk");
    'success' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    if (success != true) {
    != was unexpected at this time.
    
    C:\Users\utente\Desktop>        printf("%s\n",ftp.lastErrorText());
    'printf' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>        return;
    'return' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    }
    '}' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>
    C:\Users\utente\Desktop>    //  Upload a file.
    '//' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    CkString localFilename;
    'CkString' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\utente\Desktop>    localFilename = "hamlet.xml";
    'localFilename' is not recognized as an internal or external command,
    operable program or batch file.
    Ho provato altri codici sempre con qualche errore, sapete mica darmi una mano in modo da poter risolvere questo problema?
    Nel caso avete un sorgente per l'upload di un file su ftp con autentificazione?

    (Scusate se chiedo aiuto in questo modo ma sono molte ore che sono bloccato e non avendo tempo di partire da zero con c++ mi sento molto in difetto)

    PS gli errori avvengono tutti nella compilazione.
    Ultima modifica di ganerationZero; 28-06-2015 a 21:48

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.