Ryan32
06-25-2003, 03:17 AM
I want to list all the files in a certain directory, without having the extension on them.... And have those names (without the extensions) be links to the actual files... Would this be a simple script to do?
![]() | View Full Version : List all files in a directory, without extensions Ryan32 06-25-2003, 03:17 AM I want to list all the files in a certain directory, without having the extension on them.... And have those names (without the extensions) be links to the actual files... Would this be a simple script to do? FW-Mike 06-25-2003, 03:51 AM Yes, you'd basically need to do a while loop to echo out the files in there and create a link to the file in the loop, then also in the loop strip the file extention and echo that The loop would be like while ($f= mysql_fetch_object($result)) { echo "<a href='http://domain.com/".$f->filename."'>$stripped_name</a>"; } Obviously thats for mysql as I'm too busy to write up a complete script for you atm, but you get the point. Ryan32 06-25-2003, 04:01 AM actually i don't get it.... i'm illiterate when it comes to php.... :) Troy 06-25-2003, 04:09 AM if ($dir = opendir($path)) { $count=1; while (false !== ($filename = readdir($dir))) { if ( $filename != "." && $cache != ".." ) { $filename = explode(".", $filename); echo $filename[0]."\n"; $count++; } } } closedir($dir); FW-Mike 06-25-2003, 04:11 AM What he said :p |