C实现FTP上传操作

社区服务
高级搜索
猴岛论坛电脑百科C实现FTP上传操作
发帖 回复
倒序阅读 最近浏览的帖子最近浏览的版块
0个回复

[资源分享]C实现FTP上传操作

楼层直达
不懂也不知道

ZxID:10586231

等级: 禁止发言

举报 只看楼主 使用道具 楼主   发表于: 2010-07-18 0
C实现FTP上传操作
#include <windows.h>
#include <wininet.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include<stdio.h>
#include<time.h>
#pragma comment(lib, "wininet")

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
srand((unsigned)time(0));
int random_integer = rand();

char str[1024];
srand(time(0));
sprintf(str,"%.5d_file.txt",rand()%100000);



HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
hFtpSession = InternetConnect(hInternet, "ftp.name.com", INTERNET_DEFAULT_FTP_PORT, "user-name", "user-password", INTERNET_SERVICE_FTP, 0, 0);
FtpPutFile(hFtpSession, "C:\\log.txt", str, FTP_TRANSFER_TYPE_BINARY, 0);
InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);

Sleep(2000);

MessageBox(NULL, "Successfully uploaded to ftp server!", "Ftp Upload", MB_OK);


return 0;
« 返回列表
发帖 回复