1,105,177 Community Members

How to open paticulre folder in directory listing ?

Member Avatar
Chirag_97
Newbie Poster
9 posts since Sep 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.... 
Member Avatar
pritaeas
mod_pritaeas
11,285 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,830 [?]
Skill Endorsements: 154 [?]
Moderator
Featured
Sponsor
 
1
 

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

Member Avatar
AndrisP
Junior Poster in Training
55 posts since May 2013
Reputation Points: -3 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 1 [?]
 
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);
    }
  }
Member Avatar
Chirag_97
Newbie Poster
9 posts since Sep 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Chirag_97
Newbie Poster
9 posts since Sep 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
AndrisP
Junior Poster in Training
55 posts since May 2013
Reputation Points: -3 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 1 [?]
 
0
 

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

Member Avatar
Chirag_97
Newbie Poster
9 posts since Sep 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
AndrisP
Junior Poster in Training
55 posts since May 2013
Reputation Points: -3 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 1 [?]
 
0
 
Question Answered as of 7 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: