title: List server folders and files as tree with Folder View (PHP)
body: <p>How can I display the files and sub folders on the server in Folder View? (PHP)</p>
  
  <p>Example -</p>
  
  <p><img src="https://i.stack.imgur.com/kj3rt.jpg" alt="http://www.dmxzone.com/downloads/images/FV_FilesTree.jpg"></p>
  
  <p>I used the following code to generate the listed folders and subfolders -</p>
  
  <pre><code>&lt;?php
  function listFolderFiles($dir)
  {
      $ffs = scandir($dir);
      echo '&lt;ol&gt;';
      foreach($ffs as $ff)
      {
          if($ff != '.' &amp;&amp; $ff != '..')
          {
              echo '&lt;li style="list-style-type:square"&gt;'.$ff;
              if(is_dir($dir.'/'.$ff)) 
                  listFolderFiles($dir.'/'.$ff);
              echo '&lt;/li&gt;';
          }
      }
      echo '&lt;/ol&gt;';
  }
  listFolderFiles('C:\wamp\www');
  ?&gt;
  </code></pre>
  
  <p>Just want to know <strong>two things</strong> - </p>
  
  <ol>
  <li><p>How to have that plus-minus (expand-hide) feature on the folders?</p></li>
  <li><p>How to directly open any specific file by clicking it? It should
      open in read only mode in the default software set for that particular file extension
      in the client machine.</p></li>
  </ol>
  
  <p>Thanks in advance.</p>