How to send/receive files over the Internet in VB

How to send/receive files over the Internet in VB. What kind of control should i use......ansd how to use it...
can anybody send me the code....i need it urgently.......
kenghwangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

setiawanCommented:
kanghwang, take a look at
http://www.ostrosoft.addr.com/vb/projects/transfer.html 

or you can search at www.planet-source-code.com/vb
with keyword ftp or something you want to find


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
setiawanCommented:
if you want some code, here it is, I pasted it for you (from PAQ)
'transfer from ftp site
'need label1   winsock1  winsock2  command1
'bas module code


Option Explicit


Type Com
    BackCode As String
    Command As String
End Type

''''''''''''''''''''''''''''''''''''''''''''''''''''''

'<<<<<<<<<<<<<<<<   form   >>>>>>>>>>>>>>>>>>>>>>>>>>>> 

Option Explicit

Dim Commun(5) As Com
Dim CommunState As Integer
Dim Site As String
Dim Username As String
Dim Password As String
Dim Remotefile As String
Dim Localfile As String
Dim Buffersize As Long
Dim CloseAfterSend As Boolean


Private Sub Command1_Click()


    Site = "ftp.iprimus.ca
    Username = "xxxxxx"
    Password = "xxxxxxxxxx"
    Localfile = "c:\my documents\fix.txt"
    Remotefile = "public_html/fix.txt"
     
    Commun(0).Command = "220"
    Commun(0).BackCode = "USER " + Username
    Commun(1).Command = "331"
    Commun(1).BackCode = "PASS " + Password
    Commun(2).Command = "230"
    Commun(2).BackCode = "TYPE I"
    Commun(3).Command = "200"
    Commun(3).BackCode = "PORT"
    Commun(4).Command = "200"
    Commun(4).BackCode = "STOR " + Remotefile
    Commun(5).Command = "" 
    Commun(5).BackCode = "" 
    Buffersize = 2920
    Dim Nr1 As Integer
    Dim Nr2 As Integer
    Dim LocalIP As String
    LocalIP = Winsock1.LocalIP


    Do Until InStr(LocalIP, ".") = 0
        LocalIP = Left(LocalIP, InStr(LocalIP, ".") - 1) + "," + Right(LocalIP, Len(LocalIP) - InStr(LocalIP, "."))
    Loop

    Randomize Timer
    Nr1 = Int(Rnd * 12) + 5
    Nr2 = Int(Rnd * 254) + 1
    Commun(3).BackCode = "PORT " + LocalIP + "," + Trim(Str(Nr1)) + "," + Trim(Str(Nr2))
    Winsock2.Close


    Do Until Winsock2.State = 0


        DoEvents
        Loop

        Winsock2.LocalPort = (Nr1 * 256) + Nr2
        Winsock2.Listen
        Winsock1.Close


        Do Until Winsock1.State = 0


            DoEvents
            Loop

            Winsock1.RemoteHost = Site
            Winsock1.RemotePort = 21
            Winsock1.Connect
            CommunState = 0


            Do Until Winsock1.State = 7 Or Winsock1.State = 9


                DoEvents
                Loop



                Select Case Winsock1.State
                    Case 9
                    MsgBox "Couldn't reach server " + Site + ".", vbOKOnly + vbInformation, "FTP Upper"
                    Case 7
                    Open Localfile For Binary As #1
                End Select

        End Sub



Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Dim tmpS As String
    Winsock1.GetData tmpS, , bytesTotal
    Debug.Print tmpS;


    Select Case Left(tmpS, 3)
        Case Commun(CommunState).Command
        Winsock1.SendData Commun(CommunState).BackCode + Chr(13) + Chr(10)
        Debug.Print Commun(CommunState).BackCode
        CommunState = CommunState + 1
        Case "150"


        Do Until Winsock2.State = 7


            DoEvents
            Loop

            SendNextData
            Case "226"
            Winsock1.Close


            Do Until Winsock1.State = 0


                DoEvents
                Loop

                MsgBox "Transfer complete.", vbOKOnly + vbInformation, "FTP Upper"
                Case Else
                MsgBox "Bad Command: " + Left(tmpS, Len(tmpS) - 2), vbOKOnly + vbInformation, "FTP Upper"
            End Select

    End Sub



Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)

    Winsock2.Close


    Do Until Winsock2.State = 0


        DoEvents
        Loop

        Winsock2.Accept requestID


        Do Until Winsock2.State = 7


            DoEvents
            Loop

        End Sub



Sub SendNextData()

    Dim Take As Long
    Dim Buffer As String
    If LOF(1) - Seek(1) < Buffersize Then Take = LOF(1) - Seek(1) + 1 Else Take = Buffersize
    Buffer = Input(Take, 1)
    Winsock2.SendData Buffer


    If Take < Buffersize Then
        Close #1
        CloseAfterSend = True
    End If

    On Error Resume Next
    Label1 = Trim(Str(Seek(1))) + "/" + Trim(Str(LOF(1)))
    On Error GoTo 0
End Sub



Private Sub Winsock2_SendComplete()



    If CloseAfterSend = True Then
        Winsock2.Close


        Do Until Winsock2.State = 0


            DoEvents
            Loop

            CloseAfterSend = False
        Else
            SendNextData
        End If

    End Sub
0
setiawanCommented:
'transfer to ftp site

Option Explicit

Type Com
    BackCode As String
    Command As String
    Reply As String
    BackCommand As String
End Type

'''''''''''''''''''''''''''''''''''''''

'<<<<<<<<<<<<<  form code >>>>>>>>>>>>>>>>> 

Option Explicit

Dim Commun(5) As Com
Dim CommunState As Integer
Dim Site As String
Dim Username As String
Dim Password As String
Dim Remotefile As String
Dim Localfile As String
Dim Buffersize As Long
Dim CloseAfterSend As Boolean

Private Sub Command1_Click()

    Site = "ftp.iprimus.ca
    Username = "enyaw"
    Password = "berwhi24gau"
    Localfile = "c:\my documents\fix.txt"
    Remotefile = "public_html/fix.txt"
    Commun(0).Reply = "220"
    Commun(0).BackCommand = "USER " + Username
    Commun(1).Reply = "331"
    Commun(1).BackCommand = "PASS " + Password
    Commun(2).Reply = "230"
    Commun(2).BackCommand = "TYPE I"
    Commun(3).Reply = "200"
    Commun(3).BackCommand = "PORT"
    Commun(4).Reply = "200"
    Commun(4).BackCommand = "STOR " + Remotefile
    Commun(5).Reply = "" 
    Commun(5).BackCommand = "" 
    Buffersize = 2920
    Dim Nr1 As Integer
    Dim Nr2 As Integer
    Dim LocalIP As String
    LocalIP = Winsock1.LocalIP
     

    Do Until InStr(LocalIP, ".") = 0
        LocalIP = Left(LocalIP, InStr(LocalIP, ".") - 1) + "," + Right(LocalIP, Len(LocalIP) - InStr(LocalIP, "."))
    Loop

    Randomize Timer
    Nr1 = Int(Rnd * 12) + 5
    Nr2 = Int(Rnd * 254) + 1
    Commun(3).BackCommand = "PORT " + LocalIP + "," + Trim(Str(Nr1)) + "," + Trim(Str(Nr2))
    Winsock2.Close


    Do Until Winsock2.State = 0


        DoEvents
        Loop

        Winsock2.LocalPort = (Nr1 * 256) + Nr2
        Winsock2.Listen
        Winsock1.Close


        Do Until Winsock1.State = 0


            DoEvents
            Loop

            Winsock1.RemoteHost = Site
            Winsock1.RemotePort = 21
            Winsock1.Connect
            CommunState = 0


            Do Until Winsock1.State = 7 Or Winsock1.State = 9


                DoEvents
                Loop



                Select Case Winsock1.State
                    Case 9
                    MsgBox "Couldn't reach server " + Site + ".", vbOKOnly + vbInformation, "FTP Upper"
                    Case 7
                    Open Localfile For Binary As #1
                End Select

        End Sub



Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Dim tmpS As String
    Winsock1.GetData tmpS, , bytesTotal
    Debug.Print tmpS;


    Select Case Left(tmpS, 3)
        Case Commun(CommunState).Reply
        Winsock1.SendData Commun(CommunState).BackCommand + Chr(13) + Chr(10)
        Debug.Print Commun(CommunState).BackCommand
        CommunState = CommunState + 1
        Case "150"


        Do Until Winsock2.State = 7


            DoEvents
            Loop

            SendNextData
            Case "226"
            Winsock1.Close


            Do Until Winsock1.State = 0


                DoEvents
                Loop

                MsgBox "Transfer complete.", vbOKOnly + vbInformation, "FTP Upper"
                Case Else
                MsgBox "Bad reply: " + Left(tmpS, Len(tmpS) - 2), vbOKOnly + vbInformation, "FTP Upper"
            End Select

    End Sub



Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)

    Winsock2.Close


    Do Until Winsock2.State = 0


        DoEvents
        Loop

        Winsock2.Accept requestID


        Do Until Winsock2.State = 7


            DoEvents
            Loop

        End Sub



Sub SendNextData()

    Dim Take As Long
    Dim Buffer As String
    If LOF(1) - Seek(1) < Buffersize Then Take = LOF(1) - Seek(1) + 1 Else Take = Buffersize
    Buffer = Input(Take, 1)
    Winsock2.SendData Buffer


    If Take < Buffersize Then
        Close #1
        CloseAfterSend = True
    End If

    On Error Resume Next
    Label1 = Trim(Str(Seek(1))) + "/" + Trim(Str(LOF(1)))
    On Error GoTo 0
End Sub



Private Sub Winsock2_SendComplete()



    If CloseAfterSend = True Then
        Winsock2.Close


        Do Until Winsock2.State = 0


            DoEvents
            Loop

            CloseAfterSend = False
        Else
            SendNextData
        End If

    End Sub
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.