Error 12003 FTP File Upload Error

ftp

Hello and good evening ,

This is centered for FTP File upload using C++. I have been trying to upload an FTP File and i get Error 12003 been searching out on the web, i havent seen anything useful.. seems annoying.

My code looks like this

  #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <wininet.h>

#pragma comment (lib, "wininet.lib")

int main()
{
    HINTERNET hInternet;
    HINTERNET hFtpSession;

    hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    if(!hInternet)
    {
        printf("Error : %d\n",GetLastError());
    }

    hFtpSession = InternetConnect(hInternet, "myohyip8.5gbfree.com", INTERNET_DEFAULT_FTP_PORT, "myohyip8", "WxqHjNGv", INTERNET_SERVICE_FTP, 0, 0);

    if(!hFtpSession)
    {
        printf("Error : %d\n",GetLastError());
    }

    if (!FtpPutFile(hFtpSession, "C:\\ivan.txt", "myivan.txt", FTP_TRANSFER_TYPE_BINARY, 0))
                {
                    printf("Error : %d\n", GetLastError());
                }
        else{
            printf("File Upload Successful :)\n");
            }
        InternetCloseHandle(hFtpSession);
       InternetCloseHandle(hInternet);

        system("PAUSE");
    return 0;
}

This has been giving me worries, i dont have a single Idea on where to go from here , seems to me like a file system error.

Best Answer

The first thing I do when troubleshooting an ftp problem is to try getting a regular ftp program (e.g. filezilla, or whatever) to connect and perform the same operation on that same machine. If it can connect, you'll be able to see a log of the server conversation in that software that will give you good parameters to work with. If you cannot connect, you'll see in that same log what the problem might be.

Without using such software to be sure, my best guess is that have a problem trying to connect in regular mode and you should be in passive (essentially a firewall issue). You can pass in INTERNET_FLAG_PASSIVE in the 2nd to last parameter of your InternetConnect call. That will switch it to passive mode.

e.g.

hFtpSession = InternetConnect(hInternet, "myohyip8.5gbfree.com", INTERNET_DEFAULT_FTP_PORT, "myohyip8", "WxqHjNGv", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
Related Topic