Question Locked

Uploading in VB6

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hey guys. I need a little help with my VB6 code. I can successfully download, but I need a function to upload a file. My code is below:

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

I just need one more Function for uploading, but I can't figure it out. Any assistance would be greatly appreciated. Thanks in advance.

4 replies

by dawgit

I think I see the problem. You really should double check your code(s). -d

by dlandmesser

Hey, thanks for nothing. I really appreciate your help. You're the best.

This discussion is closed to new replies.