note 70466 deleted from function.readdir by bobby

From: Date: Wed, 18 Oct 2006 15:14:05 +0000
Subject: note 70466 deleted from function.readdir by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-118696@lists.php.net to get a copy of this message
Note Submitter: suit (at) rebell (dot) at Reason: non-english ---- simple script to read directorys and subdirectorys from a specific location and generate direct links to the file (suitable for picture gallery-listings or something like that) in the example, the file is called "directory.php" and links to it self back in 2nd line <?php echo "<a href=\"directory.php\">..</a><br>"; // startdir (tiefster, erlaubter relativer pfad zum script) // subdir (aktuelles unterverzeichnis) // subdir_n (neues unterverzeichnis (ist altes subdir + neues verzeichnis)) // dir (vollstaendiges verzeichnis (startdir + subdir)) $startdir = "rebell.shared/gfx/screenshots/"; $dir = "$startdir$subdir"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $filename = $file; $filetype = filetype($dir . $file); if ($filename == ".." OR $filename == ".") { echo ""; } elseif ($filetype == "file") { echo "<a href=\"$dir$filename\">$filename</a><br>"; } elseif ($filetype == "dir") { $subdir_n = "$subdir$filename/"; echo "<a href=\"directory.php?subdir=$subdir_n\">$filename</a><br>"; } } closedir($dh); } } ?>

« previous php.notes (#118696) next »