Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <string>
- #include <windows.h>
- #include <wininet.h>
- #include <iostream>
- #pragma comment(lib, "Wininet")
- using namespace std;
- void ftpupload(wstring &ip, wstring &user, wstring &pass, wstring &file_local, wstring &file_remote)
- {
- HINTERNET hConnection;
- HINTERNET hFtpSes;
- hConnection = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- if (hConnection == NULL) {
- cout << GetLastError();
- }
- else {
- hFtpSes = InternetConnect(hConnection, ip.c_str(), INTERNET_DEFAULT_FTP_PORT, user.c_str(), pass.c_str(), INTERNET_SERVICE_FTP, 0, 0);
- if (hFtpSes == NULL) {
- cout << GetLastError();
- }
- else {
- if (!FtpPutFile(hFtpSes, file_local.c_str(), file_remote.c_str(), FTP_TRANSFER_TYPE_BINARY, 0)) {
- cout << GetLastError();
- }
- }
- }
- }
- int main()
- {
- wstring ip(L"127.0.0.1");
- wstring user(L"admin");
- wstring pass(L"passwort");
- wstring file_local(L"C:/lokaledatei.txt");
- wstring file_remote(L"/pfadmussexistieren/aufmserver.txt");
- ftpupload(ip, user, pass, file_local, file_remote);
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement