[Webinar] Streamline your web hosting managementRegister Today

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

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.
0
donb1
Asked:
donb1
  • 8
  • 5
1 Solution
 
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
 
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
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.

 
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

Featured Post

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.

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