Hii Guys!!
I have posted previously about my predicament and was told by other members to be more specific, so here goes!
I have the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
std::ifstream f("c:\\Windows\\Temp\\Test.txt");
std::string ip;
for (int i = 1; i <= 15; i++)
std::getline(f, ip);
std::cout << ip << '\n';
HINTERNET hInternet = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
HINTERNET hFtpSession = InternetConnectA(hInternet, ip.c_str(),
INTERNET_DEFAULT_FTP_PORT, "test", "test",
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
FtpPutFileA(hFtpSession, "C:/Test.txt", "/Testing.txt", FTP_TRANSFER_TYPE_BINARY, 0);
std::cout << "\nFile Uploaded!\n";
InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);
|
Now, "ip.c_str()" contains "127.0.0.1" from line 15 of "c:\\Windows\\Temp\\Test.txt". When I inclued "ip.c_str()" into the following code, it dosnt upload the file to the FTP server.
-----
HINTERNET hFtpSession = InternetConnectA(hInternet, ip.c_str(),
INTERNET_DEFAULT_FTP_PORT, "test", "test",
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
-----
If I was to replace "ip.c_str()" with (L"127.0.0.1") it will upload the text file successfully.
Also, if I were to have (char str2[] = "127.0.0.1";) and replace the "ip.c_str()" with "str2" it does the same thing and the file does not save.
Many thanks for taking the time to read this and have a wonderful day!!