/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function listFiles($dir) { $totalSize = (int) 0; foreach($files as $file) { $cellLink = '<td class="list_files_table_file_link"><a href="/fake/files/' . $file . '">' . $file . '</a></td>'; $cellTime = '<td>' . $fileTime . '</td>'; $cellSize = '<td>' . $fileSize . '</td>'; $outRows .= '<tr>' . "\n " . $cellLink . "\n " . $cellTime . "\n " . $cellSize . "\n" . '</tr>' . "\n"; } } } $output = '<table class="list_files_table" width="100%" align="center" cellpadding="3" cellspacing="1" border="0">' . "\n"; $output .= '<thead><tr><td><b>Name</b></td><td><b>Last Modified</b></td><td><b>Size</b></td></tr></thead>' . "\n"; $output .= '<tfoot><tr><td colspan="2">' . count($files) . ' files.</td><td>' . @byte_convert($totalSize) . '</td></tr></tfoot>' . "\n"; $output .= '<tbody>' . "\n"; $output .= $outRows; $output .= '</body>' . "\n"; $output .= '</table>'; return $output; } function byte_convert($bytes) { $exp = (int) 0; $converted_value = (int) 0; if ($bytes > 0) { } } echo listFiles('/path/to/files');
URL: http://code.cshaiku.com/code_php_list_files.php