1.11M Members

How to open paticulre folder in directory listing ?

 
0
 

Here is my Code :::

 <?php

        if ($handle = opendir('images/')) {
            echo "Directory handle: $handle\n";
            echo "Entries:\n";


            while (false !== ($entry = readdir($handle))) {
                echo "$entry\n";?><br/>
            <?php }

            /* This is the WRONG way to loop over the directory. */
            while ($entry = readdir($handle)) {
                echo "$entry\n";
            }

            closedir($handle);
        }
  ?>

Output : login.php

loop1.php
My Music
My Pictures
note.xml
saveeditor.php
select.php 

In this listing MY Music is folder but i did not open the folder.... Any solution for this particular problem.... 
 
1
 

Each new folder, you want to list the contents of, needs to opened with opendir as well. It's a recursive function.

 
1
 
function my_opendir($dir) {
  if ($handle = opendir($dir)) {
    echo "<ul>Directory handle: $dir<br />Entries:";

    while (false !== ($entry = readdir($handle))) {
      if($entry=="."||$entry=="..") { continue; }
      echo "<li>";
      if(is_dir($dir.$entry)) { my_opendir($dir.$entry); }
      else { echo $entry; }
      echo "</li>";
      }
    echo "</ul>";

    closedir($handle);
    }
  }
 
0
 

@AndrisP :: Thaxs... Bur when when i click on particular folder then and then only open this folder ...

 
0
 

Hi..
How to click any file or folder in dirtectory listing ?
Any Solytion for this ?

 
0
 

in line 9 print entry as link, like: "<a href="".$entry."">".$entry."</a>"

 
0
 

Hello i want open only folder in directory listing not a file ?
There is any script avaiable in php ?

Question Answered as of 10 Months Ago by AndrisP and pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: