4 replies
by dlandmesser Accepted solution
by dlandmesser Accepted solution
Well, I made some progress. I can download easily, but I still need a function to upload. Here is the code so far:
Const INTERNET_SERVICE_FTP = 1
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_FLAG_PASSIVE = &H8000000
Const FTP_TRANSFER_TYPE_BINARY = 0
Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Sub Command1_Click()
Dim hOpen&, hConn&
Dim lRes As Long
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
hConn = InternetConnect(hOpen, "ftp.thelwcf.com", "21", "(username)", "(password)", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0)
lRes = FtpGetFile(hConn, "index.html", "C:\index.html", False, FILE_ATTRIBUTE_ARCHIVE, FTP_TRANSFER_TYPE_BINARY, 0&)
InternetCloseHandle hConn
InternetCloseHandle hOpen
End Sub
As you can see, it's simple enough. One command button to do the work. I just need one more function to allow the uploading. Any help would be more than appreciated. Thanks in advance.
by dawgit Accepted solution
by dlandmesser Accepted solution
This discussion is closed to new replies.
Trending Networks posts
Sort by Trending