SFTP Object
 
Syntax
 
SFTP.UploadFileByName(remoteFilePath As String, localFilePath As String) As Long
 
Description
Simplified method for uploading a file to the SFTP/SSH server.
The last-modified date/time is only preserved if the PreserveDate property is set to 1. This behavior of maintaining the last-mod date/time was introduced in v9.5.0.40.
 
Important: If the remoteFilePath is an absolute path, then it is a path from the root of the server's filesystem. For example, "/home/joe/someFile.txt". Use a relative path to specify a directory relative to the $HOME directory of the SSH user account. For example, "./someFile.txt".
 
Returns 1 for success, 0 for failure.
 
See Also

Example
Sub Main
 
' Set some timeouts, in milliseconds:
sftp.ConnectTimeoutMs = 15000
sftp.IdleTimeoutMs = 15000
 
' Connect to the SSH server. 
' The standard SSH port = 22
' The hostname may be a hostname or IP address.
Dim hostname As String
hostname = "sftp.example.com"
Dim port As Long
port = 22
Dim success As Long
success = sftp.Connect(hostname,port)
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
' Authenticate with the SSH server.  Chilkat SFTP supports
' both password-based authenication as well as public-key
' authentication.  This example uses password authenication.
success = sftp.AuthenticatePw("myLogin","myPassword")
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
' After authenticating, the SFTP subsystem must be initialized:
success = sftp.InitializeSftp()
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
' Upload from the local file to the SSH server.
' Important -- the remote filepath is the 1st argument,
' the local filepath is the 2nd argument;
Dim remoteFilePath As String
remoteFilePath = "hamlet.xml"
Dim localFilePath As String
localFilePath = "c:/temp/hamlet.xml"
 
success = sftp.UploadFileByName(remoteFilePath,localFilePath)
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
Debug.Print "Success."
 
End Sub