CoderZone.org

Category: >> PHP Code >> Simple directory viewer / browser Bookmark and Share

<< lastnext >>

Snippet Name: Simple directory viewer / browser

Description: This script lists files in the same directory as the script is located. Directories are not listed by deafult.

Also see:
» Active Directory - Reading the Use...
» Read a web page directly in to a s...
» Recursive Directory Browser
» Create an array from the contents ...
» Get A Directory Listing Of Specifi...
» Check If A Directory Allows File C...
» Saving Remote Images With PHP
» Include All Files In A Directory
» More File Type Detection in PHP
» Get Current Page URL
» Get Current Directory Name
» Measure script run time
» Random Image from Directory
» LOCKS: View Locked Objects
» INDEXES: View table indexes
» USERS: view specific user info
» USERS: view currently connected us...
» USERS: view all active users
» Materialized View
» VIEW
» INSERT: Multiple Column Table Or V...
» INSERT: Multiple Column Table Or V...
» INSERT: Single Column Table Or View
» Create View
» Easy page browser
» Write to File example
» Hierarchical categories browser
» Get oldest file in directory
» Check if a file exists

Comment: (none)

Author:
Language: PHP
Highlight Mode: PHP
Last Modified: December 20th, 2010

<?php 
// This script lists files in the same directory 
// as the script is located. Directories are not listed.
 
// Control what types of files that are displayed with 
// the $viewExt variable list. Filenames beginning with 
// 'index.' will not displayed. 
 
// only filenames with these extensions will be shown
$viewExt = '.html|.php|.css|.js|.txt'; 
$dirHandle = opendir('.');
while ($file = readdir($dirHandle)) {
	if ($file != '.' && $file != '..' && eregi("($viewExt)$",$file) && !eregi("^index.",$file)) {
		$stack[] = $file;   // append filename to an array
		}
	}
closedir($dirHandle);
sort($stack);
foreach($stack as $value) {
	echo '<a href="'.$value.'">'.$value.'</a><br>'."\n";
	}
?>
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7