Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all your code structure looks horrid - not sure if that was a copy and paste thing or what. But as it stands you're creating a link to the directory rather than calling the script again. Try this:</p> <pre><code>&lt;?php $dirname = ( isset($_GET['dir']) ) ? $_GET['dir'] : '/drives/Storage/AppsOSs/'; if( !$dir = opendir($dirname) ) { die("Unable to open $dirname"); } $file_list = ""; while( ($file = readdir($dir)) !== false) { if( ($file != '.') &amp;&amp; ($file != '..') ) { if( is_dir($dirname . $file) ) { $file_list .= "&lt;a href=\"" . $_SERVER['PHP_SELF'] . "?dir=" . $dirname . $file . "\"&gt;" . $file . "&lt;/a&gt;&lt;br/&gt;"; } else { $file_list .= "&lt;a href=\"$dirname/$file\"&gt;$file&lt;/a&gt;&lt;br/&gt;"; } } } closedir($dir); ?&gt; &lt;p&gt; &lt;?= $file_list; ?&gt; &lt;/p&gt; </code></pre> <p>You may need to tweak it slightly to work with your system. However the idea is: If it's a file it loads the File path directly into the browser, if it's a directory call the script again with the new dirname. You could elaborate further with something like this:</p> <pre><code>&lt;?php $dirname = ( isset($_GET['dir']) ) ? $_GET['dir'] : '/drives/Storage/AppsOSs/'; if( !$dir = opendir($dirname) ) { die("Unable to open $dirname"); } $dir_arr = array(); $file_arr = array(); while( ($file = readdir($dir)) !== false) { if( ($file != '.') &amp;&amp; ($file != '..') ) { if( is_dir($dirname . $file) ) { $dir_arr[] = "&lt;a href=\"" . $_SERVER['PHP_SELF'] . "?dir=" . $dirname . $file . "\"&gt;" . $file . "&lt;/a&gt;"; } else { $file_arr[] = "&lt;a href=\"$dirname/$file\"&gt;$file&lt;/a&gt;"; } } } closedir($dir); $dir_list = implode("&lt;br/&gt;", $dir_arr); $file_list = implode("&lt;br/&gt;", $file_arr); ?&gt; &lt;p&gt; &lt;?= "&lt;h1&gt;Directories&lt;/h1&gt;" . $dir_list . "&lt;h1&gt;Files&lt;/h1&gt;" . $file_list; ?&gt; &lt;/p&gt; </code></pre> <p>With this setup all directories will be listed first - rather than mixed alphabetically like in the first example.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload