* 上传文件到 ftp 上*------------------------------------------------
Clea
#Define INTERNET_INVALID_PORT_NUMBER 0
#Define INTERNET_OPEN_TYPE_DIRECT 1
#Define INTERNET_SERVICE_FTP 1
#Define FTP_TRANSFER_TYPE_ASCII 1
#Define FTP_TRANSFER_TYPE_BINARY 2
Public hOpen, hFtpSession
Do decl
* select FTP connection provi* you an appropriate access level
* in all cases it can not be any "anonymous" access
If connect2ftp ("222.73.4.75", "csjwn520", "152123")
* select the existing source and valid target file names
* these names are as an example only
lcSource = "f:\ftp\ftp.txt" &&不知道是什么意思?
lcTarget = "红雨/temptest.txt" &&不知道是什么意思?
lcRenamed = "红雨/角色代理.prg" &&不知道是什么意思?
* default transfer type selected -
* the file is transfered exactly as it is
If FtpPutFile (hFtpSession, lcSource,;
lcTarget, FTP_TRANSFER_TYPE_BINARY, 0) = 1
* if file (lcRenamed) already exists, most probably it would be replaced
* with the new one during the renaming
* at least my FTP server acts like this
? FtpRenameFile (hFtpSession, lcTarget, lcRenamed)
Endif
= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)
Endif
Procedure decl
Declare INTEGER InternetOpen IN wininet.dll;
STRING sAgent,; INTEGER lAccessType,;
STRING sProxyName,;
STRING sProxyBypass,;
STRING lFlags
Declare INTEGER InternetCloseHandle IN wininet.dll INTEGER hInet
Declare INTEGER InternetConnect IN wininet.dll;
INTEGER hInternetSession,;
STRING sServerName,;
INTEGER nServerPort,;
STRING sUsername,;
STRING sPassword,;
INTEGER lService,;
INTEGER lFlags,;
INTEGER lContext
Declare INTEGER FtpPutFile IN wininet.dll;
INTEGER hConnect,;
STRING lpszLocalFile,;
STRING lpszNewRemoteFile,;
INTEGER dwFlags,;
INTEGER dwContext
Declare INTEGER FtpRenameFile IN wininet.dll;
INTEGER hConnect,;
STRING lpszExisting,;
STRING lpszNew
Return
Endproc
Function connect2ftp (strHost, strUser, strPwd)
* open access to Inet functions
hOpen = InternetOpen ("vfp", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0) && 提示参数出错!出错!出错!出错!
* hOpen = InternetOpen("vfp",INTERNET_OPEN_TYPE_DIRECT,0,0,0)
If hOpen = 0
? "找不到库 WinInet.Dll 的入口"
Return .F.
Endif
* connect to FTP
hFtpSession = InternetConnect (hOpen, strHost, INTERNET_INVALID_PORT_NUMBER,;
strUser, strPwd, INTERNET_SERVICE_FTP, 0, 0)
If hFtpSession = 0
* close access to Inet functions and exit
= InternetCloseHandle (hOpen)
? "FTP " + strHost + " 无效"
Return .F.
Else
? "连接到 " + strHost + " as: [" + strUser + ", *****]"
Endif
Return .T.
Endfunc
*------------------------ 提示“参数不对!”