digitalrjs Posted August 29, 2008 Share Posted August 29, 2008 I want to display a list of documents or files for example pdfs from a set of files and open them up. <?php echo ""; //The path to the style directory $dirpath = "pdf/"; $dl = opendir($dirpath); while (false !== ($file = readdir($dl))) { //admit sub directories if (!is_dir("$dirpath/$file")) { echo "$file"; } } closedir($dl); //Close Select ?> one.pdf two.pdf three.pdf 1. I want to order the files by date 2. I want to open up the displayed files Link to comment https://forums.phpfreaks.com/topic/121803-php-file-list/ Share on other sites More sharing options...
cooldude832 Posted August 29, 2008 Share Posted August 29, 2008 try glob Link to comment https://forums.phpfreaks.com/topic/121803-php-file-list/#findComment-628431 Share on other sites More sharing options...
Barand Posted August 30, 2008 Share Posted August 30, 2008 $dirpath = "pdf/"; $dl = opendir($dirpath); while (false !== ($file = readdir($dl))) { //admit sub directories if (!is_dir("$dirpath/$file")) { $mod = filemtime("$dirpath/$file"); $files[$file] = $mod; // store in array } } closedir($dl); //Close Select asort($files); // sort array by date foreach ($files as $fn => $mod) { $dt = date ('d M y H:i:s', $mod); echo "<a href='$dirpath/$fn'>$fn</a> ($dt) <br />"; } Link to comment https://forums.phpfreaks.com/topic/121803-php-file-list/#findComment-629652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.