Class: | FTP_SERVICE |
Type | Character |
Direction | Input |
Type | Character |
Direction | Input |
Type | Character |
Direction | Input |
Type | Character |
Direction | Input |
Optional |
Type | Numeric |
Direction | Input |
Optional |
Value | Description |
INTERNET_FLAG_ASYNC | Only asynchronous requests. |
INTERNET_FLAG_FROM_CACHE | All entities are returned from the cache. |
INTERNET_FLAG_OFFLINE | All entities are returned from the cache. |
LOCAL loFTP SET PROCEDURE TO ftp.prg ADDITIVE loFTP=CREATEOBJECT('ftp_service') IF loFTP.OpenInternet("ABONNE", "PWD", "10.10.10.10", "21") IF loFTP.GetFTPFile("any.txt","local.txt") ?STRTRAN("File %File% downloaded","%File%","local.txt") ELSE ?loFTP.GetExtendedErrorCode(),loFTP.GetExtendedErrorMsg() ENDIF =loFTP.CloseInternet() ENDIF RELEASE PROCEDURE ftp.prg
LPARAMETERS INP lcUserName, INP lcPassword,INP lcIPAddress, INP lcPort, OPT_INP lnFlag LOCAL lnPCount, fResult,lnConnectHandle,liAccessType,lcProxyBypass,lcProxyName * Check Passed Parameters lnPCount = PCOUNT() IF lnPCount < 4 This.nResult_Code = ERROR_INTERNET_BAD_OPTION_LENGTH RETURN .F. ENDIF lnFlag=IIF(lnPCount<5,0,lnFlag) * Make sure parameters are of the correct type IF (TYPE("lcUserName") != "C") OR ; (TYPE("lcPassword") != "C") OR ; (TYPE("lcIPAddress") != "C") OR ; (TYPE("lcPort") != "C") This.nResult_Code = ERROR_INVALID_PARAMETER RETURN .F. ENDIF * Check Parameter Values IF EMPTY(lcUserName) OR EMPTY(lcPassword) OR EMPTY(lcIPAddress) This.nResult_Code = ERROR_INTERNET_BAD_OPTION_LENGTH RETURN .F. ENDIF IF This.LoadAPIFuncs() != ERROR_SUCCESS RETURN .F. ENDIF * Open Handle to Internet * Set Parameters This.cUserName = lcUserName + cNULL && Store FTP Connection information This.cPassword = lcPassword + cNULL This.cIPAddress = lcIPAddress + cNULL This.cPort = lcPort IF EMPTY(This.cProxyHost) OR ISNULL(This.cProxyHost) lcProxyName = .NULL. liAccessType=INTERNET_OPEN_TYPE_DIRECT This.lUseProxy = .F. lcProxyBypass=.NULL. ELSE *protocol=proxyhost:proxyport *ftp=ftp://ftp_proxy_name:21 lcProxyName = This.cProxyProtocol+"="+ This.cProxyHost + ":" + ALLTRIM(This.cProxyport) + cNULL liAccessType=INTERNET_OPEN_TYPE_PROXY This.lUseProxy = .T. lcProxyBypass=This.cIPAddress ENDIF This.nInet_Handle = InternetOpen((This.cAgent), INTERNET_OPEN_TYPE_DIRECT, @lcProxyName, @lcProxyBypass,lnFlag) This.GetExtendedError() * Unable to Get a Connection into the Internet IF This.nInet_Handle = 0 This.CloseFTPConnection() RETURN .F. ENDIF * This Opens the FTP site and Gets the Current Directory. The handle to the FTP site is opened * and closed for each call to any function. * Open FTP Site fResult=This.OpenFTPConnection(This.cStartupFolder) =IIF(This.lMultiOperations,.T.,This.CloseFTPConnection()) && Close FTP Handle RETURN fResult