-
Notifications
You must be signed in to change notification settings - Fork 3
File Listing Example
Lawrence Okoth-Odida edited this page Mar 24, 2016
·
3 revisions
- None
files/$path -> show listing of files in data/upload/public/$path
files/(.*)
<?php
return array(
'title' => 'Viewing files in "/' . $args[0] . '"',
'content' => function($path) {
$rootURL = '/files/';
$rootPath = GSDATAUPLOADPATH . 'public/';
$dir = $rootPath . $path . '/';
$folders = glob($dir . '*/');
$files = glob($dir . '*.*');
echo '<ul class="files">';
// Display "Up one level" link ...
$parent = dirname($dir) . '/';
// ...on any page except the root
if (strlen($parent) >= strlen($rootPath)) {
$parent = str_replace($rootPath, '', $parent);
echo '<li><a href="' . $rootURL . $parent . '">/</a></li>';
}
// Display folders
foreach ($folders as $folder) {
$folder = basename($folder);
echo '<li><a href="' . $rootURL . $folder . '">' . $folder . '</a></li>';
}
// Display files
foreach ($files as $file) {
$file = basename($file);
echo '<li><a href="/data/uploads/' . $path . $file . '">' . $file . '</a></li>';
}
echo '</ul>';
}
);