0

i want to upload a local file to server ( eg. 0catch.com).

i use following code ( and INET component on form)
Inet1.Execute , "PUT c:\a.txt /a.txt"

But this only creates empty file on server and not the contents.

so how to achieve upload without external software or increased complexity.

2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by mridul.ahuja
0

Drop Internet Transfer Control on the form (VB6: how to add Inet component?). Then use its execute method.

This example shows hoe to upload a file C:\Test.txt to the server.

Option Explicit

Private Declare Sub Sleep Lib "kernel32.dll" _
    (ByVal dwMilliseconds As Long)

Private Function UploadFile(ByVal sURL As String _
    , ByVal sUserName As String _
    , ByVal sPassword As String _
    , ByVal sLocalFileName As String _
    , ByVal sRemoteFileName As String) As Boolean
    'Pessimist
    UploadFile = False

    With Inet1
        .UserName = sUserName
        .Password = sPassword
        .Execute sURL, "PUT " & sLocalFileName & " " & sRemoteFileName

        'Mayhaps, a better idea would be to implement
        'StateChanged event handler
        Do While .StillExecuting
            Sleep 100
            DoEvents
        Loop

        UploadFile = (.ResponseCode = 0)
        Debug.Print .ResponseCode
    End With
End Function

Private Sub cmdUpload_Click()
    UploadFile "ftp://localhost", "", "", "C:\Test.txt", "/Level1/Uploaded.txt"
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.