CFtpClient::PutFile Method  
 
INT PutFile(
  LPCTSTR lpszLocalFile,  
  LPCTSTR lpszRemoteFile,  
  DWORD dwOptions  
  DWORD dwOffset  
);

The PutFile method transfers the specified file on the local system to the server.

Parameters

lpszLocalFile
A pointer to a string that specifies the file that will be transferred from the local system. The file pathing and name conventions must be that of the local host.
lpszRemoteFile
A pointer to a string that specifies the file on the server that will be created, overwritten or appended to. The file naming conventions must be that of the host operating system.
dwOptions
An unsigned integer that specifies one or more options. This parameter may be any one of the following values:
Value Description
FTP_TRANSFER_DEFAULT This option specifies the default transfer mode should be used. If the remote file exists, it will be overwritten with the contents of the uploaded file.
FTP_TRANSFER_APPEND This option specifies that if the remote file exists, the contents of the local file is appended to the remote file. If the remote file does not exist, it is created.
dwOffset
A byte offset which specifies where the file transfer should begin. The default value of zero specifies that the file transfer should start at the beginning of the file. A value greater than zero is typically used to restart a transfer that has not completed successfully. Note that specifying a non-zero offset requires that the server support the REST command to restart transfers.

Return Value

If the method succeeds, the return value is the server result code. If the method fails, the return value is FTP_ERROR. To get extended error information, call GetLastError.

Remarks

This method will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the FTP_EVENT_PROGRESS event will be periodically fired, enabling the application to update any user interface controls. Event notification must be enabled, either by calling EnableEvents, or by registering a callback function using the RegisterEvent method.

To determine the current status of a file transfer while it is in progress, use the GetTransferStatus method.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csftpv11.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

ChangeDirectory, EnableEvents, GetData, GetFile, GetMultipleFiles, GetTransferStatus, PutData, PutMultipleFiles, RegisterEvent, SetBufferSize, VerifyFile