Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FTP Class for VFP 5.0+
Message
From
18/11/2002 05:06:09
 
 
To
15/11/2002 01:30:15
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00716225
Message ID:
00723763
Views:
15
This message has been marked as the solution to the initial question of the thread.
Hi Wahyu,

Copy Rob Abrams class (which is defined in FTP.PRG) into a directory together with the programme FTPTEST.PRG below.

Set the VFP default directory to this location.

Make sure you are logged on to your ISP, then DO FTPTEST.PRG.

It is a cut down version of the examples that Rob gives with his class. I have added a few comments and message boxes so that you can see what is happening at each stage. If it is successful, you should end up with the file DISCLAIM1.TXT in your C:\ directory.

If you access the internet via a firewall, you may need to speak with the firewall administrator before it will work (I did). If the firewall has to store the IP address for your PC, then you won't be able to use DHCP.

If you have a paranoid system administrator, you may not have rights to access c:\.

As usual, you can include all manner of tests to make sure that when problems arise, the programme behaves sensibly. In one of my apps, the FTP ran automatically every hour, so I found that adding a log useful, to keep an eye on what was happening in the first few weeks of use.

Alan


* FTPTEST.PRG
* Load procedure holding FTP class 'ftp_service'
* If it falls over at the next step, its because the default dir needs setting.

SET PROCEDURE TO ftp.prg ADDITIVE

PUBLIC oFTP

* Create an FTP Object
oFTP = CREATEOBJECT('ftp_service')

* Load WinInet.dll, This is the windows dll used to access the ftp facilities.
IF oFTP.OpenInternet()

MessageBox("DLL Loaded", 64, "WinInet Message")

* Set oFTP properties prior to connecting to FTP site
* You can either use name of site
* oFTP.SetupFTPConnection('anonymous', 'test@aol.com', 'ftp.microsoft.com', "21")
* or use the IP address
oFTP.SetupFTPConnection('anonymous', 'test@aol.com', '207.46.133.140', "21")

IF oFTP.OpenFTPConnection()

MessageBox("FTP Connected", 64, "FTP Message")

* Get current directory into oFTP.cCurrentDir
oFTP.GetCurrDir()
MessageBox(oFTP.cCurrentDir, 64, "Current Directory")

* Change remote directory to MISC
IF oFTP.cCurrentDir='/'
oFTP.ChangeFtpDirectory('MISC')
oFTP.GetCurrDir()
MessageBox(oFTP.cCurrentDir, 64, "New Current Directory")
ENDIF

* Get DISCLAIM.TXT place it in C: root and rename it to DISCLAIM1.TXT
? "--- Receiving File from FTP Server"
IF !oFTP.GetFtpFile("DISCLAIM.TXT", "C:\DISCLAIM1.TXT", .T.)
oFTP.GetErrorCode(.T.)
ENDIF

oFTP.CloseInternet()


ELSE

MessageBox("FTP Failed to connect", 64, "FTP Message")
oFTP.GetErrorCode(.T.)

ENDIF

ELSE
MessageBox("No Connection Made", 64, "FTP Message")
oFTP.GetErrorCode(.T.)
oFTP.CloseInternet()
ENDIF

RELEASE oFTP
SET PROCEDURE TO
RELEASE ALL
CANCEL
Previous
Reply
Map
View

Click here to load this message in the networking platform