Upload a file to server

I have a text file in the current directory that I would like to upload over the internet to a server in vb5.

file is info.txt
server location is
http://www.dlrb.com/cgi-bin

I want the file, info.txt, to be copied from my computer to the cgi-bin folder at the server.
donb1Asked:
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.

mcriderCommented:
You can use the microsoft Internet Transfer Control to FTP the file to your server...

To add the control to your project, right-click the toolbox and select "Controls..." then select "Microsoft Internet Transfer Control" from the list.

The help pages on this are really good.


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
donb1Author Commented:
OK, I have the control and listed

Private Sub Inet1_StateChanged(ByVal State As Integer)
Inet1.URL = "ftp://www.dlrb.com/cgi-bin/"
Inet1.UserName = "xxxx"
Inet1.Password = "yyyy"
End Sub

I can't find out how to actually send the file.  I am using vb5.
0
mcriderCommented:
To transfer the file, put something like this in a command button:

    Inet1.URL = "ftp://www.dlrb.com
    Inet1.UserName = "xxxx"
    Inet1.Password = "yyyy"
    Inet1.Execute , "PUT c:/windows/desktop/info.txt /cgi-bin/info.txt"
    Do While Inet1.StillExecuting = True
        DoEvents
    Loop

You need to use the path to the cgi-bin directory in the Inet.Execute line...  If you need to change directory on the remote machine, you can do something like this:

    Inet1.URL = "ftp://www.dlrb.com
    Inet1.UserName = "xxxx"
    Inet1.Password = "yyyy"

    Inet1.Execute , "CD ../cgi-bin"
    Do While Inet1.StillExecuting = True
        DoEvents
    Loop

    Inet1.Execute , "PUT c:/windows/desktop/info.txt info.txt"
    Do While Inet1.StillExecuting = True
        DoEvents
    Loop


Cheers!
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!

donb1Author Commented:
That doesn't effect the transfer.  Do I need to do something to the Microsoft Internet Transfer Control settings?
0
mcriderCommented:
No, you don't have to do anything with the control other than what I showed you...

When you FTP into the site using the username "xxxx" and the password "yyyy", what do you have to do to get into the cgi-bin directory?


Cheers!
0
donb1Author Commented:
I changed it to the full path on the server "/home/public_html/cgi-bin" and I was able to transfer the file OK.  The problem is now that when I do it a second time, ie replaceing the file with a newer version, it makes vb and my exe file give an error and shuts down.  Do I need to remove the file on the server somehow before I replace it?
0
mcriderCommented:
What's the error you're getting?

to delete a file, you can do this:

    Inet1.Execute , "DELETE "/home/public_html/cgi-bin/info.txt"
    Do While Inet1.StillExecuting = True
        DoEvents
    Loop


Cheers!
file1      
0
mcriderCommented:
Oops! that Inet Execute line should have been:

   Inet1.Execute , "DELETE /home/public_html/cgi-bin/info.txt"


Cheers!
0
donb1Author Commented:
All of these things now work OK, except that when I close the application, I get an
This program has performed an illegal operation and will be shut down.  This only happens when I do the upload.
0
mcriderCommented:
Try this:

At design time, set the INDEX property of Inet1 to 0 then do this:

Load Inet1(1)

'TRANSFER YOUR FILE

Unload Inet1(1)



Cheers!
0
mcriderCommented:
That should look something like this:

    Load Inet1(1)
    Inet1(1).URL = "ftp://www.dlrb.com
    Inet1(1).UserName = "xxxx"
    Inet1(1).Password = "yyyy"

    Inet1(1).Execute , "CD ../cgi-bin"
    Do While Inet1(1).StillExecuting = True
        DoEvents
    Loop

    Inet1(1).Execute , "PUT c:/windows/desktop/info.txt info.txt"
    Do While Inet1(1).StillExecuting = True
        DoEvents
    Loop
    Unload Inet1(1)


Cheers!

0
donb1Author Commented:
Thanks much
0
mcriderCommented:
Glad I could help! Thanks for the points!


Cheers!
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.