Back to product page

PutFile method


Sends file to the server.

Type

None

Syntax

  • Basic
object.PutFile [LocalFile], [RemotePath]
The PutFile(object,LocalFile,RemotePath) syntax has these parts:
objectAn expression evaluating to an object of type wodSFTP.
LocalFileOptional. A Variant value. Full path to a file on the local computer.
RemotePathOptional. A Variant value. Full path to a file/directory on the server.

Remarks

The PutFile method will initiate the copying of a file from the local computer to the remote server that you are connected to. During the transfer, the Progress event will be fired several times, depending on your network connection speed and size of the file. When the copy is complete, the Done event will be fired.

If an error occurs during transfer, the Done event, containing ErrorCode and a description of the error, will be fired immediately and the transfer will be aborted. If you want to continue the transfer later, or you want to resend the file, initiate the PutFile method again (immediately or after reconnecting, depending on which error occurred). You may also use the Resume property to resume the transfer from the position where the error occurred.

This method can be initiated only when the State property is set to Connected. You cannot send a file if wodSFTP is busy doing something else.

Although the LocalFile argument MUST contain the full path including the filename of the file you wish to send, you can omit the RemotePath argument. For example, you can set

      RemotePath = "/tmp"

in which case wodSFTP will automatically copy it with the same name as it has locally. If you wish to specify that it is copied with another name, you should include it in the RemotePath argument.

If you don't specify the LocalFile or RemotePath arguments, wodSFTP will use the values set in the LocalPath and RemotePath properties.

No wildcards can be used for RemotePath argument. The RFC protocol specification for SFTP does not allow them.

In ASP we advise that you make the call as follows

      Sftp1.PutFile CStr(LocalFile), CStr(RemotePath)

This will ensure that wodSFTP can read the optional string parameter correctly.

Platforms

Windows