Jump to content

dmirsch

Members
  • Posts

    65
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.designsbydaina.com

Profile Information

  • Gender
    Female
  • Location
    Duluth, Minnesota

dmirsch's Achievements

Member

Member (2/5)

0

Reputation

  1. Yeah! This worked. Thanks so much!
  2. Thanks jcbones! This works. Last thing though, there are a bunch of .LCK files on the server that I do not want to show up in the list. If there an easy way to edit the coding to make those a no-show? Here's the code once again: <?php function dirContents($dir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(in_array($file,array('.','..'))) { continue; } if(is_dir($dir.'/'.$file)) { $contents[$dir.'/'.$file] = dirContents($dir.'/'.$file); } else { $contents[] = $dir . '/' . $file; } } closedir($dh); } } return $contents; } function processArray($array) { if(is_array($array)) { echo '<ol>'; foreach($array as $key => $value) { if(is_int($key)) { $name = strrchr($value,'/'); echo '<li><a href="'.$value.'">'.substr($name,1).'</a></li>'; } else { echo '<li><span style="font-weight:bold">' . $key . '</span>'; processArray($value); echo '</li>'; } } echo '</ol>'; } } processArray(dirContents('../../images')); ?>
  3. This is almost there. It gives me the following error though: Here's the code that goes on line 42: echo '<li><a href="'.$value.'">'.str_replace('/','',strstr(strrchr($value,'/'),'.',true)).'</a></li>';
  4. Close, I had to add a forward slash to make it really go to the directory. echo '<a href="'.$path.$file.'/">'.$file.'</a> is a directory'; However, I would like the code to rerun with that new directory once the hyperlink is clicked, because now it tells me, since there is no real file name listed in the hyperlink. So somehow if I'd like the coding to keep cycling through until it see no more subdirectories. Is that possible?
  5. So I used xyph's code and it is not reading anything as a directory. Here's how I modified the code: <?php $path = '../../images'; $handle = opendir($path); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if( is_dir($path.$file) ) echo '<a href="'.$path.$file.'">'.$file.'</a> is a directory'; else echo $file.' is not a directory'; echo '<br>'; } } closedir($handle); ?> The sample page is here: http://acpacenterstage.com/centerstage/centertix-managers/reading-files-in-folder.php As you can see, nothing is reading as a directory even though all but the last two are directories. Any ideas?
  6. In the MySQL help forum someone asked how to list out all the files in a directory. Another person gave the following code: <?php $handle = opendir('PUT NAME OF YOUR DIR HERE'); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo $file,'<br />'; } } closedir($handle); ?> I found this to be very helpful! However, is there a way to modify it so that if there are subdirectories, it will list those as hyperlinks so the code would run off of the subdirectory if you were to click that link? When I asked that question in the MySQL forum, I was told that it had nothing to do with PHP which I know. So that's why I am posting it here. Can anyone help?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.