function UploadWithPathR(what, toWhere, skip)

The UploadWithPathR function upload the file(s) specified in the what parameter (supports wildcards) to the toWhere destination directory on the remote file server, retaining the path of the original file and recreating it if necessary. The skip parameter is an integer number that instructs the function to skip the first N directories of the original path when rebuilding it into the destination path. This function is recursive, therefore when using wildcards, this function will also upload all matching files from sub-directories of the directory specified in the what parameter.


 var scli = new SftpClient();
 scli.Host = '';
 scli.User = 'someusername';
 scli.KeyFile = './my_id.rsa';
 if (scli.Connect()) {
  // perform your file transfers...
  // ...
  scli.UploadWithPathR('./data/docs/*.docx', '/archive', 0); // uploads files to /archive/data/docs and subfolders
  // ...
  scli.UploadWithPathR('./data/docs/*.docx', '/archive', 1); // skip=1 means uploads files to /archive/docs and subfolders
  // ...
 scli = null