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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.