Link to home
Start Free TrialLog in
Avatar of ingenito
ingenitoFlag for United States of America

asked on

How to FTP?

Hello,

  Actually I have a couple questions.  The first is, is there a way to FTP a file on the local computer to a server on the internet?  If so, is there an easy way to do this?  Could you please provide some code to do so?  All I need to do is upload one text file and then disconnect.

Thanks...
Avatar of aut
aut

1. Yes, what you are trying to do can be done.

2. For an easy way to do this, use the INet control...

However, this will increase the size of your application dramatically. For sample source code to an advanced way to do it (using the WinInet API), check out this url:
http://support.microsoft.com/support/downloads/LNP470.asp

The link you are looking for is titled:
"VBFTP.EXE: FILE: VBFTP.EXE: Implementing FTP Using WinInet API from VB"

Or you can download the source code directly from:
http://support.microsoft.com/download/support/mslfiles/VBFTP.EXE
(note: you have to register your copy of VB before you can download)
Avatar of ingenito

ASKER

aut,

  Thanks, but I already had that program, but it was very confusing.  If you could, please tell me the way using the INET Control or tell me the code I need to use with the example above just to FTP a simple file.  I'll increase the points. Thanks.
by example above, I mean the WinINet API
To transfer the file, put something like this in a command button:

    Inet1.URL = "ftp://www.yoursite.com
    Inet1.UserName = "yourusername"
    Inet1.Password = "yourpassword"
    Inet1.Execute , "PUT c:/windows/desktop/yourfile.txt Yourfile.txt"
    Do While Inet1.StillExecuting = True
        DoEvents
    Loop


Cheers!
By the way, my answer uses the WinInet Control...


Cheers!
A good free ftp control can be downloaded at http://www.fp.gvn.net/bradley/xFtp/xftpprod.htm.

It includes full documentation, and allows for monitoring the progress of the file transfer, which the M$ Inet cannot. (This is very important for long downloaads, when you want to provide the user with some feedback as to what is going on)
mcrider,


   How do I declare this variable?  And what is the WinInet control named?  The only control I see when adding is 'Microsoft Internet Control'.  Is that the right one?
To add the WinInet Control, right-click on the toolbox (the window where you select textboxes, pictureboxes, labels, etc.) and select "Components...".

Scroll down in the box until you see "Microsoft Internet Transfer Control" and select it from the list (MSINET.OCX).

Make sure you have VB Service Pack 3 installed... There are quite a few fixes in this service pack...

See Visual Studio 97 Service Pack 3 - Readme
http://msdn.microsoft.com/vstudio/sp/vs97/readme.asp 
 

Hope this helps!


Cheers!
mcrider,

  I do not have that control listed.  All I have listed is 'Microsoft Internet Controls'.  Is that the same thing?  If not, where can I get it.  Also, what is the call I would use to declare the variable?  dim Inet as what??  thanks!
No, they are not the same...

Microsoft Internet Controls is SHDOCVW.DLL
Microsoft Internet Transfer Controls is MSINET.OCX

What version on VB do you have?  If you have VB5 or VB6, have you installed Service Pack 3?

Look on your system for MSINET.OCX...


Cheers!
mcrider,

  I'm sorry, I bought the Learning Edition of VB which apparantly does not come with msinet.ocx.  Thanks though.
ASKER CERTIFIED SOLUTION
Avatar of Belatucadros
Belatucadros

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi all,

I am using "Internet Transfer Control" to send file to other servers. I am able to send file for one server like:
   Inet1.URL = "ftp://www.yoursite.com
   Inet1.UserName = "yourusername"
   Inet1.Password = "yourpassword"
   Inet1.Execute , "PUT c:/windows/desktop/yourfile.txt Yourfile.txt"

Could anyone knows how to disconnect FTP after sending a file to be able to resend to another server.
Also how to sent a file to multi FTP servers.

Pl help, thankyou.
Regards
Smilie