Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Directories file listing 1

Status
Not open for further replies.

ScottCybak

Programmer
Sep 29, 2000
48
CA
I'm trying to get a script on my website to display the contents of one of the folders.

Eg, i want to output the file names and sizes from the dir " on my web server

i usually search the php.net manual, but i haven't been able to access it for a few days and i'd like to complete this script.

Thanks in advance! Scott Cybak
scott@athree.com
 
Try this:
Code:
if ($dh=opendir("yourdir")) {
  while ($file=readdir($dh)) {
    if (($file!=".") AND ($file!="..")) {
      echo &quot;<BR>\n&quot;;
      if (is_dir(&quot;yourdir/&quot;.$file)) {
        echo &quot;<EM>&quot;.$file.&quot;</EM>&quot;;
      } else {
        echo $file;
      }
    }
  }
  closedir($dh);
}

Hope this helps
-Rob
 
Ah, thanks, works like a charm.. now all i have to do is apply some formatting and i'm set

Thanks again! Scott Cybak
scott@athree.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top