Class: | FTP_SERVICE |
Type | Character |
Direction | Input |
Type | Character |
Direction | Input |
Type | Character |
Direction | Input |
Type | Character |
Direction | Input |
Optional |
Type | Numeric/Array |
By reference | |
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. |
Value | Description |
INTERNET_OPEN_TYPE_DIRECT | Resolves all host names locally. |
INTERNET_OPEN_TYPE_PRECONFIG | Retrieves the proxy or direct configuration from the registry. |
INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY | Retrieves the proxy or direct configuration from the registry and prevents the use of a startup Microsoft JScript® or Internet Setup (INS) file. |
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
#INCLUDE "ftp.h" LOCAL loFTP LOCAL ARRAY laFlags(_FTPS_FA_MaxSize) laFlags(_FTPS_FA_Default)=0 laFlags(_FTPS_FA_AccessType)=INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY SET PROCEDURE TO ftp.prg ADDITIVE loFTP=CREATEOBJECT('ftp_service') IF loFTP.OpenInternet("ABONNE", "PWD", "10.10.10.10", "21",@laFlags) 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_INVALID_PARAMETER 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. lcProxyBypass=.NULL. liAccessType=IIF(TYPE("lnFlag("+LTRIM(STR(_FTPS_FA_AccessType,11))+")")="N",lnFlag(_FTPS_FA_AccessType),INTERNET_OPEN_TYPE_DIRECT) This.lUseProxy = .F. ELSE *protocol=proxyhost:proxyport *ftp=ftp://ftp_proxy_name:21 lcProxyName = This.cProxyProtocol+"="+ This.cProxyHost + ":" + ALLTRIM(This.cProxyport) + cNULL lcProxyBypass=This.cIPAddress liAccessType=INTERNET_OPEN_TYPE_PROXY This.lUseProxy = .T. ENDIF This.nInet_Handle = InternetOpen((This.cAgent), liAccessType, @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