PutFile Method  
 

Copy a file from the local system to the server.

Syntax

object.PutFile(LocalFile, [RemoteFile], [Offset])

Parameters

LocalFile
A string that specifies the name of the file that will be uploaded from the local system. The file pathing and name conventions must be that of the local host. You must have permission to open this file for reading.
RemoteFile
A string that specifies specifies the name of the file to create on the server. You must have permission to create or overwrite the file. This is an optional argument; if it is omitted, the value of the Resource property will be used. It is also permissible to specify a complete URL and the file will be uploaded to that location.
Offset
An optional integer argument that specifies the byte offset where the file transfer will begin. This argument is only valid for FTP servers, and is used to resume interrupted transfers.

Return Value

A value of zero is returned if the method succeeds. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

The PutFile method copies an existing file from the local system to the server. If the local file already exists, it is overwritten.

Note that not all servers honor the request to restart a file transfer. Notably, a Windows IIS server will return an error if a non-zero restart offset is specified. It is not recommended that you restart text file transfers since differences between end-of-line characters can result in byte offset differences between the local and server system.

If the AppendFile property is True, then the file contents will be appended to the file specified on the server, if it exists. Otherwise, the remote file will be overwritten.

Note that PutFile for HTTP requires that the server support the PUT command. This typically requires that you specify version 1.1 of the protocol and authenticate the client session with a user name and password.

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Example

nError = FileTransfer1.PutFile(strLocalFile, strRemoteFile)
If nError > 0 Then
    MsgBox FileTransfer1.LastErrorString, vbExclamation
    Exit Sub
End If

See Also

AppendFile Property, URL Property, GetData Method, GetFile Method, PostFile Method, PutData Method, PutMultipleFiles Method