FtpPutFile()调用失败,错误号12018,如何解决?
**功能:实现上传文件到服务器#Define INTERNET_INVALID_PORT_NUMBER 0
#Define INTERNET_OPEN_TYPE_DIRECT 1
#Define INTERNET_OPEN_TYPE_PROXY 3
#Define INTERNET_DEFAULT_FTP_PORT 21
#Define INTERNET_FLAG_ASYNC 268435456 && &H10000000
#Define INTERNET_FLAG_FROM_CACHE 16777216 && &H1000000
#Define INTERNET_FLAG_OFFLINE 16777216
#Define INTERNET_FLAG_CACHE_IF_NET_FAIL 65536 && &H10000
#Define INTERNET_OPEN_TYPE_PRECONFIG 0
#Define FTP_TRANSFER_TYPE_ASCII 1
#Define FTP_TRANSFER_TYPE_BINARY 2
#Define INTERNET_SERVICE_FTP 1
#Define INTERNET_SERVICE_GOPHER 2
#Define INTERNET_SERVICE_HTTP 3
#Define FILE_ATTRIBUTE_NORMAL 128 && 0x00000080
Declare INTEGER InternetOpen IN wininet STRING sAgent, INTEGER lAccessType, STRING sProxyName,STRING sProxyBypass, STRING lFlags
Declare INTEGER InternetCloseHandle IN wininet INTEGER hInet
Declare INTEGER InternetConnect IN wininet INTEGER hInternetSession, STRING sServerName,INTEGER nServerPort, STRING sUsername,STRING sPassword, INTEGER lService, INTEGER lFlags, INTEGER lContext
Declare INTEGER FtpPutFile IN wininet INTEGER hFtpSession, STRING lpszRemoteFile,STRING lpszNewFile, INTEGER fFailIfExists,INTEGER dwFlagsAndAttributes,INTEGER dwFlags, INTEGER dwContext
DECLARE LONG GetLastError IN Kernel32.dll
sAgent = "var1"
sProxyName = Chr(0)
sProxyBypass = Chr(0)
lFlags = 0
hOpen = InternetOpen (sAgent, INTERNET_OPEN_TYPE_DIRECT,sProxyName, sProxyBypass, lFlags)
If hOpen = 0
=MESSAGEBOX("找不到库 WinInet.Dll 的入口",16,"警告")
Return
Endif
*在此修改自己的FTP服务器数据
strHost = "https://spritedown.oss-cn-hangzhou. &&存放升级文件的FTP服务器地址
strUser = "null" &&升级的FTP用户名
strPwd = "null" &&FTP用户密码
hFtpSession = InternetConnect (hOpen, strHost,0,null,null,3, 0, 0) &&改为3,过了
If hFtpSession = 0
= InternetCloseHandle (hOpen)
=MESSAGEBOX("找不到指定的服务器",16," 警告")
Return
Endif
*以下设置FTP的路径和文件名
lpszRemoteFile = "https://spritedown.oss-cn-hangzhou.
lpszNewFile = "e:\农资小精灵\test1.txt"
fFailIfExists = 0
dwContext = 0
lnResult = FtpPutFile (hFtpSession, lpszRemoteFile, lpszNewFile,fFailIfExists,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,dwContext)
If lnResult # 1
? "errnum:", GetLastError()
? "上传文件失败!"
Endif
= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)