Skip to content

Instantly share code, notes, and snippets.

@growdigital
Created May 4, 2012 11:19
Show Gist options
  • Save growdigital/2594196 to your computer and use it in GitHub Desktop.
Save growdigital/2594196 to your computer and use it in GitHub Desktop.
PHP Directory listing
<?php
/* Function that reads directory content and
returns the result as links to every file in the directory
also it disply type wheather its a file or directory
for any help please contact Chetan Akarte... */
function DirDisply($data) {
$TrackDir=opendir('.');
while ($file = readdir($TrackDir)) {
if ($file == '.' || $file == '..' || $file == '.DS_Store') {
// do nothing
} else {
$info = pathinfo($file);
$file_name = basename($file,'.'.$info['extension']);
print '<li class="type '.$myfile_icon.'"><a href="'.$file.'" target="'.$myfile_target.'">'.$file.'</a></li>';
}
}
closedir($TrackDir);
return $data;
}
function DescDisplay($data) {
$TrackDir=opendir('.');
closedir($TrackDir);
return $data;
}
?>
<?php @ DescDisplay($data);?>
<ul><?php @ DirDisply($data);?></ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment