Click or drag to resize

CFtp.PutFile Method

X#
Store a file on the FTP server.

Namespace:  VO
Assembly:  VOInternetClasses (in VOInternetClasses.dll) Version: 2.19
Syntax
 VIRTUAL METHOD PutFile(
	cLocalFile,
	cRemoteFile,
	lFailIfExists,
	nFlags
) AS USUAL CLIPPER
Request Example View Source

Parameters

cLocalFile (Optional)
Type: Usual
Name of the local file that is to be sent to the remote FTP server.
cRemoteFile (Optional)
Type: Usual
String that contains the name of the file to create on the remote FTP server. If not specified, <cLocalFile> automatically becomes the name of the remote file.
lFailIfExists (Optional)
Type: Usual
Logical value indicating whether the method should proceed if a remote file of the specified name already exists. If lFailIfExists is TRUE and the remote file exists, method PutFile() fails.
nFlags (Optional)
Type: Usual
Flags that control how the function will handle the file upload and the conditions under which the transfers occur. The application should select one transfer type and any of the flags that control how the caching of the file will be controlled. The transfer type can be any one of the following values: The application can use one or more of the following values to control the caching of the file:

Return Value

Type: Usual
TRUE if successful; otherwise, FALSE.
Remarks
This method handles all of the necessary processes associated with reading a file locally and storing it on an FTP server.
Examples
The following receives the comprehensive list (00index.txt) of all files contained in the X# download section at ftp.cai.com:
X#
 1FUNC TestGetFile()
 2LOCAL oFTP  AS CFtp
 3LOCAL cFile AS STRING
 4oFTP := CFtp{"VO Sample FTP Agent"}
 5IF oFTP:ConnectRemote("ftp.cai.com", ;
 6                       "anonymous",   ;
 7                       "Darth.Vader@starwars.com")
 8cFile := "00index.txt"
 9IF oFTP:SetCurDir("/pub/vo")
10IF oFTP:GetFile(cFile)
11IF File(cFile)
12? "File received: " + FPathName()
13ENDIF
14ELSE
15__RaiseFTPError(oFTP)
16ENDIF
17ELSE
18__RaiseFTPError(oFTP)
19ENDIF
20oFTP:CloseRemote()
21RETURN
22STATIC FUNC __RaiseFTPError (oFTP AS CFtp) AS INT PASCAL
23LOCAL cError    AS STRING
24LOCAL nRet      AS INT
25nRet := oFTP:Error
26IF nRet > 0
27cError := oFTP:ErrorMsg
28IF SLen(cError) > 0
29MessageBox(0, cError, "FTP Error", MB_OK)
30ENDIF
31ENDIF
32RETURN nRet
See Also