PutFTPFile Method
Class: FTP_SERVICE
This method sends a file to the FTP server from some local area. Depending on how the FTP Server is setup, decides whether or not an existing file is overwritten or if the function fails to send the file.
=
Object.PutFTPFile
Parameter
lcRemoteFile
Remote file name
Type Character
Direction Input
Name and Path for the contents of the file to be stored in.
This parameter cannot be empty.
lcLocalFile
Local file name
Type Character
Direction Input
Name and Path of the file to send to the FTP Server.
This parameter cannot be empty.
lnFlag
The flags that indicate various options.
Type Numeric
Direction Input
Value is combined with FTP_SERVICE::nCachingType's value and FTP_TRANSFER_TYPE_BINARY . Can be one of the following:
ValueDescription
FTP_TRANSFER_TYPE_ASCII Transfers the file as ASCII.
FTP_TRANSFER_TYPE_BINARY Transfers the file as binary.
Assumed from MSDN.
Return value Boolean
Returns .T. if the function successfully copied the file to the FTP Server. Returns .F. if the operation failed.
Example
LOCAL loFTP
SET PROCEDURE TO ftp.prg ADDITIVE 
loFTP=CREATEOBJECT('ftp_service') 

IF loFTP.OpenInternet("ABONNE", "PWD", "10.10.10.10", "21")
   IF loFTP.PutFTPFile("any.txt","local.txt")
      ?STRTRAN("File %File% uploaded","%File%","local.txt")
   ELSE
      ?loFTP.GetExtendedErrorCode(),loFTP.GetExtendedErrorMsg()
   ENDIF
   =loFTP.CloseInternet() 
ENDIF
RELEASE PROCEDURE ftp.prg
See also
Expand/Collapse source code of procedure PutFTPFile Source Code
      LPARAMETERS INP lcRemoteFile, INP lcLocalFile, INP lnFlag
      LOCAL fResult
      IF EMPTY(lcRemoteFile) OR EMPTY(lcLocalFile)
         RETURN .F.
      ENDIF
      lnFlag=IIF(PCOUNT()<3,0,lnFlag)
      IF This.OpenFTPConnection(This.cStartupFolder)     && Open an FTP Handle
         lcRemoteFile = lcRemoteFile + cNULL
         lcLocalFile = lcLocalFile + cNULL

         =This.BeforePutFTPFile(@lcRemoteFile, @lclocalFile,lnFlag)
         fResult = FtpPutFile(This.nConnect_Handle, @lcLocalFile, @lcRemoteFile, ;
                              BITOR(FTP_TRANSFER_TYPE_BINARY,BITOR(This.nCachingType,lnFlag)), 0)
         =This.GetExtendedError()
         =This.AfterPutFTPFile(@lcRemoteFile, @lclocalFile,lnFlag,fResult)

         =IIF(This.lMultiOperations,.T.,This.CloseFTPConnection())   && Close FTP Handle

         RETURN  fResult = 1
      ENDIF
      RETURN .F.