1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <string>
#include <ws2tcpip.h>
#pragma comment(lib,"wininet.lib") /*This links wininet lib only works on Visual Studio VC++ */
#include<wininet.h>
#include <fstream>
int main() {
std::ifstream f("c:\\Windows\\Temp\\Test.txt");
std::string t;
for (int i = 1; i <= 15; i++)
std::getline(f, t);
char* example = new char[t.size() + 1];
std::copy(t.begin(), t.end(), example);
example[t.size()] = '\0';
printf("\n");
printf(example);
HINTERNET hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
HINTERNET hFtpSession = InternetConnect(hInternet, example, INTERNET_DEFAULT_FTP_PORT, L"test", L"test", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
FtpPutFile(hFtpSession, L"C:/test.txt", L"/test.txt", FTP_TRANSFER_TYPE_BINARY, 0);
printf("File Uploaded!");
InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);
}
|