title: php sftp file or folder
body: <p>i am attempting to create a web based sftp page, the only part i am having problems with is trying to determin the the listed file is a file or folder. i am sucessfully listing a directory using </p>
  
  <pre><code>$connection = ssh2_connect($_SESSION['Server'], $_SESSION['Port']);
  if(ssh2_auth_password($connection, $_SESSION['Username'], $_SESSION['Password']))
  {
      $sftp = ssh2_sftp($connection);
      $dir = "ssh2.sftp://$sftp/$directory";
      $handle = opendir($dir);
      while (false !== ($file = readdir($handle))) 
      {
          if ($file != "." &amp;&amp; $file != "..")
          {
              $temp=$file;
              if(strlen($directory) &gt; 0)
                  $Path=$directory."/".$file;
              else
                  $Path=$file;
  
              $statinfo = ssh2_sftp_stat($sftp, "/".$Path);
              echo "&lt;a href=\"list.php?dir=".urlencode($Path)."\"&gt;$temp&lt;/a&gt;&lt;br /&gt;";
          }
      }
       closedir($handle);
  }
  </code></pre>
  
  <p>i attempted to use the is_dir() and is_file() php function on $file which works sucessfully when working on local filesystem, but when using SFTP both come back FALSE, i attempted to use ssh2_sftp_stat() but this only gives uid, gid, size access and modified times and i dont think there is anyting that can be used to identify files of folders, if anyone has a way to resolve this i would appreaciate it greatly</p>
  
  <p>Vip32</p>