注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

且行且记录

点滴记录,行的更远!

 
 
 

日志

 
 

FTP上传文件测试  

2014-09-09 16:59:05|  分类: 一些练习 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

试了下ftp上传文件测试

#include <windows.h>
#include <wininet.h>
#pragma comment(lib, "wininet.lib")

int main(int argc, char* argv[])
{
 HINTERNET hInternet;
 HINTERNET hFtpSession;

 hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
 hFtpSession = InternetConnect(hInternet, "vxp", INTERNET_DEFAULT_FTP_PORT, "anonymous", "password", INTERNET_SERVICE_FTP, 0, 0);
 
 if(FtpPutFile(hFtpSession, "C:\\temp\\vc\\tk1.dll", "\\root\\tk1.dll", FTP_TRANSFER_TYPE_BINARY, 0)){
  printf("[+] ftp upload file OK!\n");
 }else{
  printf("[-] ftp upload file NG!\n");
 }

 InternetCloseHandle(hFtpSession);
 InternetCloseHandle(hInternet);
 
 return 0;
}

参考:http://msdn.microsoft.com/zh-cn/subscriptions/aa914148.aspx

FtpPutFile

A version of this page is also available for
4/8/2010

This function stores a file on the FTP server.

FTP上传文件测试 - appall - 且行且记录Syntax

BOOL WINAPI FtpPutFile(
  HINTERNET hConnect, 
  LPCTSTR lpszLocalFile, 
  LPCTSTR lpszNewRemoteFile, 
  DWORD dwFlags, 
  DWORD dwContext
);
FTP上传文件测试 - appall - 且行且记录Parameters

hConnect

[in] Valid handle to an FTP session.

lpszLocalFile

[in] Long pointer to a null-terminated string that contains the file name to send from the local system.

lpszNewRemoteFile

[in] Long pointer to a null-terminated string that contains the file name to create on the remote system.

dwFlags

[in] Specifies the conditions under which the transfer occurs. The following table shows the possible values for this parameter. The values can be used in any combination.

Value Description

INTERNET_FLAG_DONT_CACHE

Does not add the returned entity to the cache. Identical to the preferred value INTERNET_FLAG_NO_CACHE_WRITE.

INTERNET_FLAG_HYPERLINK

Forces a reload if there was no Expires time and no Last-Modified time returned by the server when determining whether to reload the item from the network.

INTERNET_FLAG_MUST_CACHE_REQUEST

Causes a temporary file to be created if the file cannot be cached. Identical to the preferred value INTERNET_FLAG_NEED_FILE.

INTERNET_FLAG_NEED_FILE

Causes a temporary file to be created if the file cannot be cached.

INTERNET_FLAG_NO_CACHE_WRITE

Does not add the returned entity to the cache. If the INTERNET_FLAG_HYPERLINK is also specified, WinInet will create the cache file but will not commit it.

INTERNET_FLAG_RELOAD

Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.

INTERNET_FLAG_RESYNCHRONIZE

Performs a conditional download of the file.

INTERNET_FLAG_TRANSFER_ASCII

Transfers the file as ASCII.

INTERNET_FLAG_TRANSFER_BINARY

Transfers the file as binary.

dwContext

[in] Specifies an application-defined value that associates this search with application data. This parameter is used only if the application has already called InternetSetStatusCallback to set up a status callback. All status requests are handled synchronously.

FTP上传文件测试 - appall - 且行且记录Return Value

TRUE indicates success. FALSE indicates failure. To get extended error data, call GetLastError.

FTP上传文件测试 - appall - 且行且记录Remarks

This function is a high-level routine that handles all the bookkeeping and overhead associated with reading a file locally and storing it on an FTP server. An application that needs to send file data only, or that requires close control over the file transfer, should use the FtpOpenFile and InternetWriteFile functions.

If the dwTransferType parameter specifies FILE_TRANSFER_TYPE_ASCII, translation of the file data converts control and formatting characters to local equivalents.

Both lpszNewRemoteFile and lpszLocalFile can be either partially or fully qualified file names relative to the current directory. A backward slash (\) or forward slash (/) can be used as the directory separator for either name. FtpPutFile translates the directory name separators to the appropriate character before they are used.

FTP上传文件测试 - appall - 且行且记录Requirements

Header wininet.h
Library wininet.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later
  评论这张
 
阅读(161)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017