Jump to content


Photo

Displaying files of subdirectories


  • Please log in to reply
1 reply to this topic

#1 Macintosh

Macintosh

    Young Padawan

  • Members
  • Pip
  • 28 posts

Posted 26 March 2008 - 06:59 PM

Hey.. I need some help about How can i list files with thin the subdirectories...
Following code only display the directories.. i want to display subdirectory files too. I dont want to display sub directory files on the index page..in the way that on the index file it shows the list of subdirectories.. and when i click on any subdirectory, it displays the files of that subdirectory. I would appriciate any help..

<?
$path = "./";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "<a href=\"$file\">$file</a><br />";
}
closedir($dir_handle);
?>

#2 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 March 2008 - 01:19 AM

Listing files of a subdirectory is a very common question, and a frequently answered one as well. I don't know if you will find it having been asked on this forum, but on google, you definately will.
For example, a site you should bookmark: http://php.net/manua...addir.php#75156




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users