Important alert: (current site time 7/16/2013 4:11:00 AM EDT)
 

VB icon

Make Your Own FTP Client

Email
Submitted on: 4/30/1999
By: Vikramjit Singh  
Level: Not Given
User Rating: By 105 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 83771
 
     Make a simple FTP Client that allows you to read and write to a remote computer
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Make Your Own FTP Client
' Description:Make a simple FTP Client that allows you to read and write to a remote computer
' By: Vikramjit Singh
'
' Inputs:The IP address and local file name , path.
'
' Assumes:Set Project Refrences to MSINET.OCX before you run the code
Or you could set Project components and check on Microsoft Internet transfer control...then drag the MSINET control onto the form.In that case comment the line
'Dim Inet1 As New InetCtlsObjects.Inet
'
' Side Effects:'******************NOTE**************
' This code runs fine on a local intranet... for ALL versions of VB.
' This code has also been tested by me to work on the INTERNET for VB5
' (SP3). if you have VB5 PLEASE upgrade to SP3...to resolve known
' bugs in INET. The code will then run like a breeze. VB 5 SP3 is FREE
' at http://www.microsoft.com/msdownload/vstudio/sp97/vb.asp
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1698&lngWId=1'for details.'**************************************

' Dim Inet1 As New InetCtlsObjects.Inet
Dim FTPHostname As String
Dim Response As String
Public Sub writefile(pathname As String, filename As String, IPaddress As String)
'note ..your ip addres specified should be that of an anonymous FTP Server.
'otherwise use ftp://ftp.microsoft.com kind of syntax
 FTPLogin
 FTPHostname = IPaddress
 Inet1.Execute FTPHostname, "PUT " & pathname & filename & " /" & filename
 Do While Inet1.StillExecuting
 DoEvents
 Loop
 Exit Sub
End Sub
Public Sub getfile(pathname As String, filename As String, IPaddress As String)
'note ..your ip addres specified should be that of an anonymous FTP Server.
'otherwise use ftp://ftp.microsoft.com kind of syntax
 FTPLogin
 FTPHostname = IPaddress
 Inet1.Execute FTPHostname, "GET " & filename & " " & pathname & filename
 Do While Inet1.StillExecuting
 DoEvents
 Loop
 Exit Sub
End Sub
Private Sub FTPLogin()
With Inet1
.Password = "Pass"
.UserName = "Anonymous"
End With
End Sub


Other 11 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
5/1/1999 7:31:00 AMIan Ippolito

Input paramaters:
IpAddress=url and diretory of file
example:ftp.microsoft.com
FileName=name of file to download
example:disclaimer.txt
PathName=local path name
example:c:\
(If this comment was disrespectful, please report it.)

 
5/2/1999 8:52:00 AMBen Sullivan

What if I wanted to log on to an ftp site that requires a user name and password? Could you update this code to support that feature?
(If this comment was disrespectful, please report it.)

 
5/4/1999 6:30:00 PMMarc

you could try the following...
Inet1.URL = "FTP://ftp.domain.tld"
Inet1.Password = "dummypass"
Inet1.UserName = "dummyuser"
Text1.Text = Inet1.OpenURL
(If this comment was disrespectful, please report it.)

 
5/6/1999 2:13:00 AMAamir Nizami

can u demonstrate me how u develop this code
i mean what is the theme of this code
how this code will work
plz reply me
I shall be very thankful to u
u can also e-mail to me on
naamir@mailcity.com

(If this comment was disrespectful, please report it.)

 
5/7/1999 5:21:00 PMJeff

can you please send me a form of the whole FTP codes and everything I need a example so I can understand how to work it please I would appreciate it cause the .bas file doesnt help me any. Thankyou!
(If this comment was disrespectful, please report it.)

 
5/10/1999 9:56:00 PMIan

im trying to make a program that downloads a file in the background and then displays it in a text box once its done, can this be done with this code?? if not does anyone know hos i could and send me an example, i really need it..Email me PLEASE!!!!! THANKS IN ADVANCE
(If this comment was disrespectful, please report it.)

 
5/11/1999 4:38:00 AMLatexRat

hmm.. seems like people are having trouble?! I would explaine, but i dont have the time right now.. If you are interested in me making an example please email me! I can whip one up real quick.. Also any questions .. Email me w/ them also ..


(If this comment was disrespectful, please report it.)

 
5/11/1999 1:03:00 PMBirk

I am trying to find a way to list directories that are located on a web server in a treeview. When a directory is choosen the files within that directory would be listed in a listview. Sort of like windows explorer only for remote directories and files in my assigned space on a web server. Any help or samples would be appreciated. email me at birk@home.com thanks.
(If this comment was disrespectful, please report it.)

 
5/11/1999 11:41:00 PMThomas Bachleitner

The following piece of program does not work. It
hangs at the Inet1.Execute command and does
not return at least for 1 minute (the host is
in the LAN).
Please help!

thank you in advance!
----------------------------
Public Sub getfile()
Inet1.Protocol = icFTP
FTPHostname = "myhost"
Inet1.URL = "ftp://" + myhost
Inet1.Password = "passw"
Inet1.UserName = "usern"
Debug.Print Inet1.OpenURL
Inet1.Execute FTPHostname, "GET /path/tmp/prn.out c:\prn.out"

Do While Inet1.StillExecuting
DoEvents
Loop
Exit Sub
End Sub

(If this comment was disrespectful, please report it.)

 
5/16/1999 9:38:00 PMSmokeDoGG

can you please send me a form of the whole FTP codes and everything I need a
example so I can understand how to work it please I would appreciate it cause
the .bas file doesnt help me any. Thank you!
(If this comment was disrespectful, please report it.)

 
5/18/1999 4:00:00 AMMarcus

The code works ok, but when transferring text files from a remote computer all the carriage return characters are stripped out (vbCrLfs). Does anyone else have the same problem, or is it a one off case?

Cheers
(If this comment was disrespectful, please report it.)

 
5/18/1999 12:14:00 PMLatexRat

I made a simple little example out of it... You can get it at:
members.xoom.com/808games/ftpsamp.zip
Any Questions w/ it just email me :)
(If this comment was disrespectful, please report it.)

 
5/19/1999 2:02:00 AMArjan Almekinders

instead of Inet1.Execute FTPHostname, "PUT " & pathname & filename & "/ " & filename

I'd use
Inet1.Execute FTPHostname, "PUT " & Chr(34) & pathname & filename & "/" & Chr(34) & " " & Chr(34) &filename&Chr(34)

This way, it is possible to download files with large names containing spaces.
& Chr(34) &
(If this comment was disrespectful, please report it.)

 
5/19/1999 2:12:00 AMArjan Almekinders

Another issue coming up here:
How do I transfer the files and save them in DOS-mode (ie chr(10)+chr(13) instead of just chr(10) on the end of each line)?
(If this comment was disrespectful, please report it.)

 
5/19/1999 8:19:00 PMVbmaster

Has anyone here worked with the API's (no .ocx!) on FTP-transfers, i would like to find the information needed to get a progressbar working, what is used some kind of callback-function? Thnx.
(If this comment was disrespectful, please report it.)

 
5/20/1999 12:18:00 AMPGPKeys

Hey, great code!. This is one of the few VB mailing lists i actually subscribe to. I've learned more here than from any book. Glad to see otehrs like this author sharing the knoeledge a bit.

My question kind of applies to this. I run both Windows and Linux. The problem I have with any FTp (including that done withthis code) is taht under Windows any text file I get comes in with Crl+Lf codes embedded (just part of how Windows hadnels EOL chars i guess. I need to be able to have it download a text file (for like perl scripts and such) and have it strip out those codes before it saves the file locally. Yet I also want the option to let the ftp client know if i want the Win95/98 format (leaving the coes in the text) or if I want to save in a format compatable with Linux. (The removal of the EOl chars). Any ideas?
Thanks in advance.

PGPKeys
(If this comment was disrespectful, please report it.)

 
5/21/1999 12:58:00 AMVikramjit Singh

Please Upgrade your VB 5 to SP3 (Service Pack 3) at http://www.microsoft.com/msdownload/vstudio/sp97/vb.asp

This code should then work just fine. I have tested it on SP3. over the internet.

(If this comment was disrespectful, please report it.)

 
5/22/1999 2:13:00 AMLiam

Im trying to make a program that can upload some text to my website, and then another program that retrieves it, anyone gt any idea's??
Thanx in advance
(If this comment was disrespectful, please report it.)

 
5/22/1999 11:47:00 PMTim Hall

This is kind of related, i want to be able to send binary and ascii files
from one client application to another alot like the ICQ file transmission
(a bit more reliable if possible) without having to buy an acitve x control
free ones are ok though any help would be greatly apprieciated please email
me at timhall@tig.com.au or ICQ me on 26185027.

(If this comment was disrespectful, please report it.)

 
5/24/1999 3:19:00 PMtyler robbins

i am trying to intergrate this with a internet chat program i made, so that you can transfer files between users. Any ideas of how i could do this? if you can email me and ill send you my source
(If this comment was disrespectful, please report it.)

 
5/27/1999 9:03:00 AMMichael

Hi, the code is very nice, i developed very rapid a few days ago a kind of same code. What I like to know is, is it possible to download automatically more than 1 datafile, I tried a lot with 1 is no problem but with more than 1, I think it must be easy, but I don't see it. Did anybody have an idea.
you can write to my e-mail adress thank you
(If this comment was disrespectful, please report it.)

 
5/27/1999 11:48:00 AMLatexrat

Ian, you cannot do that in Visual Basic.
Try assembly.

(If this comment was disrespectful, please report it.)

 
6/8/1999 1:04:00 AMPaul

hey!

i am trying to get this code to work in
VB4, and no luck. i need a thing called
msinet.ocx, and the only one i've been
able to download from the 'net, is one
that won't let me use it in a development
environment. am i missing something
here??!? or can't i use this code in VB4?

any help would be great!

my email is pennington.p@hbs.net.au
(If this comment was disrespectful, please report it.)

 
6/10/1999 5:07:00 AMManny Popes

Hi guys,

Just thinking can we make this FTP sending and receiving in Passive mode?

(If this comment was disrespectful, please report it.)

 
6/22/1999 12:19:00 PMBob

can you please send me a form of the whole FTP codes and everything I need a
example so I can understand how to work it please I would appreciate it cause
the .bas file doesnt help me any. Thankyou!

(If this comment was disrespectful, please report it.)

 
7/12/1999 10:28:00 PMvbeast

Thanks for the zip file LatexRat.
(If this comment was disrespectful, please report it.)

 
7/19/1999 6:32:00 PMzu

Can you please send me the whole program
'cause i really need it for my project.
i'll be grateful then, thanks.

(If this comment was disrespectful, please report it.)

 
7/28/1999 11:08:00 AMAdam

Can someone please help me to understand how to make a simple ftp program that works perfect, I can't find any simple examples anywhere, i'm trying to use inet and I don't get it, does anyone know of a sample program with explicit instruction within the code?
(If this comment was disrespectful, please report it.)

 
8/2/1999 4:39:00 AMCraig

I need to develop a piece of code which
will dump and entire directory of files
including sub directories onto a FTP
server. The code needs to run on its
own since this will be automated.

Can anyone please help ??
Regards
Craig
(If this comment was disrespectful, please report it.)

 
8/3/1999 9:32:00 AMKen

Nice piece of Code. What has to be done to get it to work with sFTP. I want to automate it to get a daily log file that is on a sFTP server?
(If this comment was disrespectful, please report it.)

 
8/5/1999 11:39:00 AMnaveen rao

I was working on the same code and have done exactly the same thing. But as many of them have commented, I could transfer files but only in binary mode. My project requirement is that I transfer files in text (ASCII) mode. I have upgraded to SP3 but still I have the same problem. Has anyone solved this?? Please revert ASAP

Thanks
Navs

(If this comment was disrespectful, please report it.)

 
8/7/1999 8:20:00 PMWyatt

Nice code ... but:
I think I have the reverse problem from Navs.
I can open a command prompt, ftp to the server, and put a binary or text file.
However, with Inet it will only PUT a text file. I need to ftp a binary. I'm using VB6...
and very desparate.

Thanks,
Wyatt
(If this comment was disrespectful, please report it.)

 
8/13/1999 8:46:00 PMEric

Nice, but does anybody have some ftp server source to go with it? That would be helpful. Thanks!
(If this comment was disrespectful, please report it.)

 
8/13/1999 10:40:00 PMneed2know

can you actually get files from other peoples computers?
(If this comment was disrespectful, please report it.)

 
8/17/1999 11:15:00 AMjohn

it doesn't seem to work, here's what i got
Call getfile("C:\windows\desktop\", "main.htm", "server13.hypermart.net/blike/")

someone please mail me or help me out, thanks
john
(If this comment was disrespectful, please report it.)

 
8/24/1999 6:28:00 AMLogan

I am trying to do this, but I need to display all the files in the current directory on a file list box or however they did it in CuteFTP.
(If this comment was disrespectful, please report it.)

 
8/26/1999 5:00:00 PMDC

How do you code a fix block or variable block for uploading to a mainframe environment???
(If this comment was disrespectful, please report it.)

 
8/27/1999 10:08:00 AMDoug

Does anyone have a solution to the problem of missing VbCrLf's when using this control to GET a file from a remote computer????
(If this comment was disrespectful, please report it.)

 
8/29/1999 2:36:00 AMxWz24

can anyone teach me how to continue downloads on the internets, like GetRight & Go!Zilla??? email me and we'll talk
(If this comment was disrespectful, please report it.)

 
9/11/1999 8:57:00 AMmaoak

Why i can't access intranet network?
Error "icConnectFailed 35754 "Unable to connect to remote host"
Please send mail to me.
(If this comment was disrespectful, please report it.)

 
10/19/1999 7:59:00 AMRaider

Hello, I was looking over this code and found it to be very useful in developing my own FTP Client.
Alot of people have listed problems about getting it to log onto a remote host that is running
Private Server software. To acomplish this you have to make your program han a With while Executing
and send your Inet1.UserName and Inet1.Password and it will work, I just tested this theory before
writing this Message and it worked just fine.
(If this comment was disrespectful, please report it.)

 
1/7/2000 6:04:37 PMZaid

hi there,

does any one know how to create a directory on the server thorugh vb??? lemme no if u do.

---thanks
(If this comment was disrespectful, please report it.)

 
2/16/2000 2:37:29 PMrsine

I tried using this code to access an ftp server outside my firewall and can never make a connection. I use the OpenURL and can get through but really need to use Execute for efficiency. I use a Web proxy server (i.e. web."myproxysever".com). Can you offer me any advice or point me in the direction of someone who can? I would be grateful for the help.
(If this comment was disrespectful, please report it.)

 
3/16/2000 9:50:18 AMJulie

The Internet Transfer Control is great if there are no binary/ASCII issues, but it cannot resolve an ASCII requirement. I found a great article on EarthWeb by Chris Eastwood called "FTP Access through a Class Module for VB5/6 WinInet.DLL". There is an attached project that you can download. Also I downloaded a free FTP ActiveX Control from DevPower the other day which works fairly well, although it didn't have the degree of control over processing that I wanted.
(If this comment was disrespectful, please report it.)

 
10/2/2000 6:21:06 PMBrian G.

Winning award for using a control???
What is this world comming to?
(If this comment was disrespectful, please report it.)

 
11/13/2000 9:31:03 PMdesperate

i find this codes useful but its not what i really need...well im a yr2 student sudent IT at some college...currently having my attachment...the company had asked me to develop a visual basic program...but im not sure how to go about it...
HELP ME PLS!!!!


CASE SCENARIO:

The Company has an SQL database that is being updated many times during the day. As a backup, the company has an FTP website by which they upload onto several times during the day.

THE TASK:

To create a VISUAL BASIC v6.0 program which will run a query every hour on the SQL database. If there is a change in the database, the program will upload the new database containing the new information onto the FTP website. Should there be a disruption on the filr transfer, the program will reload the information were the file is disrupted.
(PS> XML preferred)

(If this comment was disrespectful, please report it.)

 
1/8/2001 4:31:01 PMthatgirl@tsixroads.com

I am using the execute command and I need to transfer a file in ASCII mode. There has to be a way to do it!! I have a file that has been FTP'd from a UNIX machine so when it comes down it's messed up. Does anyone know how to specify the transfer mode? ANY help would be appreciated.
(If this comment was disrespectful, please report it.)

 
5/1/2002 8:10:40 AMmaia

Ok. I'm obviously missing something. I do'nt seem to have this msinet.ocx on my machine. There's a Microsoft Internet Control but it's a .dll. Please point me in the right direction.
thanx
(If this comment was disrespectful, please report it.)

 
10/26/2002 11:35:46 AM

I am unable to
(If this comment was disrespectful, please report it.)

 
10/26/2002 11:38:43 AM

I am unable to "PUT" a file in ASCII(text). It sends it in BINARY. I am referencing the MSINET.OCX in an ASP.
Is there a setting or code I need to include to send in ASCII?
(If this comment was disrespectful, please report it.)

 
5/23/2003 5:53:45 AMDrew Tempelmeyer

I am trying to make a P2P program, I may use this method
(If this comment was disrespectful, please report it.)

 
12/16/2004 2:45:05 AM

My English is not good!Sorry because I can't write much! please share "Make Your Own FTP Client" code for me. Thankyou very much!
(If this comment was disrespectful, please report it.)

 
12/16/2004 2:46:59 AM

Please send this code for me. Email: thaona@hn.vnn.vn. Thanks!
(If this comment was disrespectful, please report it.)

 
2/20/2005 3:48:14 PM

i would like to write a chat program that is able to do FTP as well. can you please send me the coding for this program?thanks for your help.
(If this comment was disrespectful, please report it.)

 
2/20/2005 3:49:31 PM

this is my email add. cyfchang901@hotmail.com
(If this comment was disrespectful, please report it.)

 
3/2/2005 1:33:56 PM

The variable
(If this comment was disrespectful, please report it.)

 
3/2/2005 1:37:13 PM

You do not define the variable "Inet1", do you?
(If this comment was disrespectful, please report it.)

 
4/7/2005 1:12:09 AM

Hi,

Please let me have some sample code to build Secure FTP client using VB6.

Thanks,
Amzad Basha.
(If this comment was disrespectful, please report it.)

 
11/13/2008 10:04:23 PMRhine Rene Mendoza

The topic is FTP that's why i'm writting this asking how can I share my files in my computer without uploading to the internet??
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.