[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Visual Basic and FTP

I am needing to write a VB app that will send a simple text file to a directory on our web site.  I am needing to do this through FTP and the site does require a User Name and password.  Right now we use an FTP program to connect to the site and use it to upload files to a chosen directory.   I am wanting to automate this process of uploading.  These text files are used by cgi scripts to build parts of the web pages.  I simply have no experience automating FTP
0
abaldwin
Asked:
abaldwin
1 Solution
 
abaldwinAuthor Commented:
Am rejecting the answer to allow for other posts.  I have downloaded the files from the URL's you posted and will examine them to see how they fit.

Of course if that gets me to the point I need to be at I will accept the answer.  Thank you for the quick response.
0
 
mcriderCommented:
You can use the Microsoft Internet Transfer Control (MSINET.OCX) to FTP program...

See the EXECUTE method help pages of the control for more information...


Basically it works like this:

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
'WAIT UNTIL WE'RE FINISHED EXECUTING THE CD COMMAND.
        Do
          DoEvents
        Loop Until Not Inet1.StillExecuting
    Inet1.Execute , "SEND c:/autoexec.bat testfile"
'WAIT UNTIL WE'RE FINISHED EXECUTING THE SENDCOMMAND.
        Do
          DoEvents
        Loop Until Not Inet1.StillExecuting Inet1.Execute , "CLOSE"



0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
dwalexCommented:
I didn't know anything about FTP when I wanted to enable a VB app as an FTP client. Using the freeware FTP client DLL from France made it very simple. You'll find your answer there.
0
 
mhjordanCommented:
Try this.  It's a "quick and dirty" way of FTPing.

Sub Main()
Dim strFilename
strFilename = "C:\WINNT\system32\Cmd.exe"

 Shell (strFilename)
 SendKeys "~FTP Servername~", True
 SendKeys "FTP Servername~", True
 SendKeys "username~", True
 SendKeys "password~", True
 SendKeys "put filename~", True
 SendKeys "bye~", True
 SendKeys "exit~", True
End Sub

The tilde (~) signs are necessary.  They indicate a line break.  Don't ask me why, but I have always had to send the FTP statement twice, because the first one invariably ends up getting cut off.

The FTP Servername opens a file transfer protocol connection to your server.  The username and password are self-explanatory.  The "put" statements puts a file onto the server.  "bye" shuts down the FTP connection and "exit" exits the command prompt.  Like I said... it's quick and dirty, but it does the trick most of the time.
0
 
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now