FTP C++ HELP

I HAVE this source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
#include<windows.h>
#include<Wininet.h>

using namespace std;


int main()
{
    HINTERNET hInternet;
    HINTERNET hFtp;
    InternetOpen(0,INTERNET_OPEN_TYPE_DIRECT,0,0,0);
    hFtp = InternetConnect(hInternet,"ftp.luxarhosting.be",INTERNET_DEFAULT_FTP_PORT,"username","mypass",INTERNET_SERVICE_FTP,0,0);
    char szFile[] = "log.txt";
    char szFilePath[MAX_PATH];
    unsigned long ulPathSize = GetFullPathName(szFile,MAX_PATH,szFilePath,0);
    szFilePath[ulPathSize] = '\0';
    FtpPutFile(hFtp,szFile,"test.txt",INTERNET_FLAG_TRANSFER_BINARY,0);

    InternetCloseHandle(hFtp);
    InternetCloseHandle(hInternet);
    return 0;

}


Is the source correct?
Because when i go to my ftp nothing has come...
Well it's hard to tell by just looking at it, but is log.txt a file in the same directory of your executable?
Check functions return values to see if there is some error.

FTP protocol requires 2 open connections on 2 different ports when you transfer a file. Also is the connection opened in active or passive mode ?

If you are behind a NAT or router without port forwarding you must use passive mode, active mode will not work.
Topic archived. No new replies allowed.