Upload using VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • douglandmesser
    New Member
    • Feb 2008
    • 10

    #1

    Upload using VB6

    Hey guys. I need a little help uploading from VB6. I've done all of the leg work, but I need the last little bit of help. My current code is below:

    [CODE=vb]Const INTERNET_SERVIC E_FTP = 1
    Const INTERNET_OPEN_T YPE_DIRECT = 1
    Const INTERNET_FLAG_P ASSIVE = &H8000000
    Const FTP_TRANSFER_TY PE_BINARY = 0
    Const FILE_ATTRIBUTE_ ARCHIVE = &H20
    Private Declare Function InternetOpen Lib "wininet.dl l" Alias "InternetOp enA" (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.dl l" Alias "InternetConnec tA" (ByVal hInternetSessio n 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.dl l" Alias "FtpGetFile A" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttri butes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
    Private Declare Function InternetCloseHa ndle Lib "wininet.dl l" (ByVal hInet As Long) As Integer

    Private Sub Command1_Click( )
    Dim hOpen&, hConn&
    Dim lRes As Long
    hOpen = InternetOpen(sc UserAgent, INTERNET_OPEN_T YPE_DIRECT, vbNullString, vbNullString, 0)
    hConn = InternetConnect (hOpen, "ftp.thelwcf.co m", "21", "(username) ", "(password) ", INTERNET_SERVIC E_FTP, INTERNET_FLAG_P ASSIVE, 0)
    lRes = FtpGetFile(hCon n, "index.html ", "C:\index.html" , False, FILE_ATTRIBUTE_ ARCHIVE, FTP_TRANSFER_TY PE_BINARY, 0&)
    InternetCloseHa ndle hConn
    InternetCloseHa ndle hOpen
    End Sub[/CODE]

    This all works great for downloading, but I need another Function to enable uploading. I just can't figure it out. Any help would greatly appreciated. Thanks in advance.
    Last edited by Killer42; Feb 29 '08, 01:31 AM. Reason: Added CODE=vb tag
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    It seems reasonable to assume there would be a corresponding FtpPutFile function that would have the desired effect. This is just guesswork on my part, though.

    Comment

    Working...