Hi all
In this question:
http://www.experts-exchange.com/Web/Web_Languages/Q_21833113.htmlI got some handy assistance generating an HTML page that lists all the files in a given folder, and making them available for download. The one I'm using is this one (see original thread above for author credit):
<?php
function make_row ($s) {
return "<tr><td>$s</td><td><a href='files/$s'>Download</
a></td></t
r>\n";
}
$files = glob('*');
// Fetch all file names
$files = array_map("make_row", $files);
// Format the file names for output
$str = implode("", $files);
// Join the array to make it a string
$str = "<table border='1' bordercolor='white'><col style='background-color: #CCCCFF;'></col><col style='background-color: #9999FF;'></col>$str</tabl
e>";
// Format it further
echo $str;
// Print the string.
?>
What I'd like to do next is:
- Specify a directory for the file listing (so I can list files from a dir other than the one the script exists in)
- Make a left-click trigger a 'Save file as...' dialog box, rather than relying on users right-clicking
- Show the date and time of the files listed
- Not show the complete path to the file on the page - just the filename. I appreciate the path has to exist in the link to the file, of course.
Thanks !
Simon
Start Free Trial