title: Files not uploading to remote server with Net_SFTP
body: <p>I have the following class for uploading files in a directory, however, the first directory that should be created is getting set up as 'File' rather then a 'File Folder'. Because of that, the items that should be uploaded are not uploading properly. I'm not sure if I am missing a step or not or if I set this up incorrectly.</p>
  
  <p>
  
  <pre><code>include 'Net/SFTP.php';
  
  class SFTPConnection
  {
      private $sftp;
  
      public function __construct($host, $username, $password)
      {
          $this-&gt;sftp = new Net_SFTP($host);
          if (!$this-&gt;sftp)
              error_log("Could not connect to $host.");
  
          if (!$this-&gt;sftp-&gt;login($username, $password))
              error_log("Could not authenticate with username $username " .
                "and password $password.");
      }
  
      public function uploadFiles($dir, $to, $from) {
          $result = array();
          $toDir = str_replace($from, $to, $dir);
          $cdir = scandir($dir);
  
          foreach ($cdir as $key =&gt; $value) {
              if (!in_array($value, array(".", ".."))) {
                  if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                      if(!$this-&gt;sftp-&gt;mkdir($toDir . DIRECTORY_SEPARATOR .$value)) {
                          echo "Could not create directory &lt;br&gt;'";
                          exit();
                      }
                      $result[$value] = $this-&gt;uploadFiles($dir . DIRECTORY_SEPARATOR . $value, $to, $from);
                  } else {
                      $result[] = $value;
                      echo "Uploading $dir/$value &lt;br&gt;";
                      if(!$this-&gt;sftp-&gt;put($toDir . DIRECTORY_SEPARATOR . $value, $dir . DIRECTORY_SEPARATOR . $value, NET_SFTP_LOCAL_FILE)) {
                          echo "Could not upload file &lt;br&gt;";
                          exit();
                      }
                  }
              }
          }
          return $result;
      }
  }
  </code></pre>