housefire
05-08-2006, 06:58 PM
Im basically looking to see if anyone has any ideas where i can find a simple php script that will basically just look into a folder and make a listing page with a link to every file in that folder.
![]() | View Full Version : simple script to display a link to mp3s in a folder? housefire 05-08-2006, 06:58 PM Im basically looking to see if anyone has any ideas where i can find a simple php script that will basically just look into a folder and make a listing page with a link to every file in that folder. orbitz 05-08-2006, 07:03 PM here is to start: http://us2.php.net/readdir PlanetWebHost 05-08-2006, 09:49 PM here ya go... ( pretty much copy&paste from orbitz's link ) $path = '/path/to/mp3s/'; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ( substr($file, -1, 3) == "mp3" ){ echo '<a href="'.$path.$file.'">'.$file.'</a><br />'; } } closedir($handle); } you'll want to watch your $path, this script assumes the path and the url are the same. foobic 05-08-2006, 11:03 PM .htaccess Options +Indexes Burhan 05-09-2006, 03:29 AM Shorter version of PlanetWebHost's snippet: $listing = glob("*.mp3"); foreach($listing as $filename) { echo '<a href="http://www.domain.com/directory/'.$filename.'">'.$filename.'</a><br />'; } Elliot A 05-09-2006, 07:25 AM Check out CeleronDude's Directory Indexer: http://www.celerondude.com/script_indexer I use it myself and find it quite nice housefire 05-10-2006, 12:42 PM thanks guys. |