Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FTP Service Class
Message
 
 
To
02/04/2002 21:24:06
Mike Smith
Doncaster Office Services
Oakville, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00640200
Message ID:
00640331
Views:
269
Hi Mike,

Here is the program we use to put files through FTP (we didn't try the reverse operation):
*:FTPOPTION.PRG
* Create a FTP Object if it does not exist
lparameter cUserId,cPassword,cFtpAddr,cTheFile,cFtpFile,cFtpPath, tlSilentMode
if vartype(m.sz_ftp)#'O'
	sz_ftp = newobject('ftp_service',"ftp.prg")
endif
*:adding message here also
local lcReturn, lcSetSafety, s
lcReturn=".T."

* Try to get a handle into the Internet and Connect Briefly with the FTP Site
* Note: Insert your USER ID, PASSWORD, FTP ADDRESS, PORT # Here
* Note: ("21" is the Default Port)
lcSetSafety = set('safety')
set safety off

if sz_ftp.OpenInternet(m.cUserId,m.cPassword, m.cFtpAddr, "21")
*	=strtofile("Successful Connection", "FTP_Messages.txt")

* Copy up a file to the server
*: putFtpFile("remote file name and path","local File name and path"

*:Adding this code to position to ftp path specified in customer table if specified
* Change to that directory
	if !empty(m.cFtpPath)
*? "--- Changing Directory to FTP Directory " + cftppath
*:Check if directory found
		if !sz_ftp.ChangeFtpDirectory(m.cFtpPath)
			s=sz_ftp.GetErrorCode(.t.)
			lcReturn=".F.Can not change directory"  && Set to false if - Will use this as a check as to whether
&& files sending is in order. If false will drop through that code
&& and return the error
		endif
	endif

*:Check to see if directory change (where applicable) generated an error.  If so do not
*:perform file transfer
	if m.lcReturn =".T."
		if !sz_ftp.PutFtpFile(m.cFtpFile, m.cTheFile)
			lcReturn=".F.Can not put file "+ m.cFtpFile+" on the FTP Site"
		else
			lcReturn = ".T."
		endif
	endif
	sz_ftp.CloseInternet()
else
	if not m.tlSilentMode
		=messagebox("No Connection Made", 64, "FTP Message")
	endif
	sz_ftp.CloseInternet()
	lcReturn=".F.No Connection Made"
endif
*sz_ftp.release()
release sz_ftp
*:Adding message here also
return m.lcReturn
>I downloaded a Class called FTP Service Class (written by Robert Abraham) from this forum.
>
>I don't know if there is anyone here who has worked with this.
>
>I just cannot get to first base with this class. Everything I try results in error messages that come from inside the class code.
>
>The Wininet.dll is available and I have copied it into my default directory to help out. I also have the ftp.prg inside the default directory.
>
>Some of my test code below. Each line starting from SZFTP.AUTODIALINTERNET(1) onward causes error messages.
>
>If anyone here has actually used this class, I would appreciate your comments as to does it actually work and how could I adjust my code below to make it work.
>
>Mike Smith
>*******************
>SET ESCAPE ON
>SET PROCEDURE TO FTP.PRG ADDITIVE
>
>SZFTP = CREATEOBJECT('ftp_service')
>
>SZFTP.AUTODIALINTERNET(1)
>
>SZFTP.OPENINTERNET("b1ztxk88@sympatico.ca", "MDSMITH1", "http://www.sympatico.com", "21")
>
>SZFTP.GOONLINE('ftp.west-wind.com')
>
>SZFTP.GETFTPFILE('ftp.west-wind.com/updates/wwreader.xml', 'C:\TEMPRENT\WWREADER.XML', .F.)
>
>SZFTP.AUTODIALHANGUP()
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform