FTP a file

I need to know how to FTP a text file up to a server and append to one that's already there. I would prefer to use the 'inet' control if at all possible, since I already have that one in my project.
LVL 2
cantrellAsked:
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.

VBGuruCommented:
Using the State Event with the GetChunk Method
When you are downloading data from a remote computer, an asynchronous connection will be made. For example, using the Execute method with the operation "GET", will cause the server to retrieve the requested file. When the entire file has been retrieved, the State argument will return icResponseCompleted (12). At that point, you can use the GetChunk method to retrieve the data from the buffer. This is shown in the example below:
Private Sub Inet1_StateChanged(ByVal State As Integer)
      Dim vtData As Variant ' Data variable.
      Select Case State
      ' ... Other cases not shown.
      Case icResponseCompleted ' 12
            ' Open a file to write to.
            Open txtOperation For Binary Access _
            Write As #intFile

            ' Get the first chunk. NOTE: specify a Byte
            ' array (icByteArray) to retrieve a binary file.
            vtData = Inet1.GetChunk(1024, icString)

            Do While LenB(vtData) > 0
                  Put #intFile, , vtData
                  ' Get next chunk.
                  vtData = Inet1.GetChunk(1024, icString)
            Loop
            Put #intFile, , vtData
            Close #intFile
      End Select
End Sub
0
mcriderCommented:
This is how you use FTP with the INET control...  The following will send the file "c:\autoexec.bat" to the host "caas.com".  The remote file will be called "testfile" and will be put in the  directory called "incoming":

    Inet1.URL = "ftp://caas.com" 'CHANGE caas.com TO REMOTE HOSTNAME
    Inet1.Password = "noneofyourbusiness" 'Password to logon to remote
    Inet1.UserName = "mcrider" 'UserID to logon remote
    Inet1.Execute , "CD incoming" 'Change remote dir to incoming
    Inet1.Execute , "SEND c:/autoexec.bat testfile"


Unfortunately, the INET control does not support appending to files...  It will overwrite the file...



Cheers!
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
cantrellAuthor Commented:
Good answer. However, you forgot to put the      
'WAIT UNTIL WE'RE FINISHED EXECUTING THE CD COMMAND.
        Do
          DoEvents
        Loop Until Not Inet1.StillExecuting

after the "Inet1.Execute , "CD incoming" 'Change remote dir to incoming" line, which you need. Otherwise, you'll get 'still executing last command' message when trying to do the upload.

thanks.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
Oops! Sorry, I was just typing the code directly into EE and didn't actually run the code...


Thanks for the points! Glad I could help!


Cheers!
0
mcriderCommented:
I also forgot this to end the FTP Session:

Inet1.Execute , "CLOSE"


Cheers!




0
cantrellAuthor Commented:
Perfect. Thank you very much.
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.