I am using a 30 day trial to test the SFTP Library. I can upload a local file to a SFTP site but it always is written to the root "." Directory. I have tried to use absPath = sftp.RealPath(".", "/dest")
But file is still uploaded to the "." Directory.
How do I change the directory?
SFTP is Secure File Transfer over SSH. It is not the FTP protocol. There is no similarity or relationship between FTP and SFTP. Therefore, concepts such as “current remote directory” that exist in FTP do not exist with SFTP. With the SFTP protocol, the current directory will always be the home directory of the user account used during SSH/SFTP authentication. You may pass relative or absolute directory/file paths. A relative path is always relative to the home directory of the SSH user account. See this blog post for more details about absolute paths: SFTP Absolute Directory Paths
Further clarification: “SFTP” is the Secure File Transfer Protocol over SSH. It is a protocol unrelated to the FTP protocol. The Chilkat SSH / SFTP component is used for “SFTP”. SFTP is achieved by connecting to an SSH server at port 22.
On the other hand, the Chilkat FTP2 components is for FTP. FTP servers listen at port 21 (non-SSL/TLS) and port 990 (SSL). FTP over SSL (i.e. port 990) is called “FTPS”. (not SFTP)
You don't "change directories". If you are calling the UploadFileByName method, then the remoteFilePath argument would be something like "./subdir1/subdir2/myFile.dat" and the localFilePath would be the path (relative or absolute) of the file in the local filesystem.
For any method having a remote path argument, you would specify either the path relative to the HOME directory of the SSH user account, or the absolute path from the root of the remote filesystem. I would always recommend using the relative path from the HOME directory.
This does not work when you do not know whether you are connecting to a Windows or Linux server who use different slashes in the paths.
Uploading to /home/dir/myfile or homedirmyfile are not compatible.
It is not working. We upload using: FTPDirectory = "batches" lsFileName is the full path to the local file "D:DIRDIRP504_PIStatement.txt" lsOnlyFileName is the file name without the path, here it is "P504_PIStatement.txt"
lxHandle = pxSFTP.OpenFile(Destination.FTPDirectory & "" & lsOnlyFileName, "writeOnly", "createNew") lbSuccess = pxSFTP.UploadFile(lxHandle, lsFileName)
And on the Linux SFTP server they are getting this: