FTPPut

Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO All

Syntax

FTPPut (socket,localfile,remotefile) Returns status

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded, allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

FTPPut uploads a local file to the FTP server. The file is transferred according to the currently specified transfer type of ASCII or binary as specified by the FTPType command. It is important that you set the transfer type correctly for each file you upload, since an incorrect transfer type will result in a bad uploaded copy of the file.

Socket is an Omnis Long Integer field containing a socket opened to an FTP server using FTPConnect.

LocalFile is an Omnis Character field containing the pathname of the file to upload.

RemoteFile is an Omnis Character field containing the pathname of the destination file on the FTP server.

Status is an Omnis Long Integer field which receives the result of executing the command. Possible error codes are listed in the Web Command Error Codes Appendix.

Example

# upload an ascii file to a FTP server
# set file transfer mode to asci
FTPType (iFTPSocket,0) Returns lErrCode
If not(lErrCode)
  Calculate lLocalFileName as con(sys(115),'uploadFolder',sys(9),'myTextFileToUpload.txt')
  Calculate lRemoteFile as 'myUploadedFile.txt'
  # upload the file to the current working directory on the FTP server, the file name will be myUploadedFile.txt
  FTPPut (iFTPSocket,lLocalFileName,lRemoteFileReturns lErrCode
  If lErrCode
    FTPGetLastStatus (iServerReplyTextReturns lErrCode
    OK message FTP Error {[con("Error uploading file",upp(lLocalFileName)," to ",upp(lRemoteFile),kCr,"Details follow: ",kCr,iServerReplyText)]}
  End If
End If