RE: [PHP] file list and linking...

From: Date: Wed, 20 Dec 2000 05:01:55 +0000
Subject: RE: [PHP] file list and linking...
Groups: php.general 
Request: Send a blank email to php-general+get-31153@lists.php.net to get a copy of this message
Just use $DOCUMENT_ROOT example: $dir = '/music/'; $basedir = $DOCUMENT_ROOT.$dir; now you can use $basedir for system path and $dir for linking purposes. Cheers, Maxim Maletsky -----Original Message----- From: Doug Stewart [mailto:doug@qpalzm.com] Sent: Wednesday, December 20, 2000 1:59 PM To: php-general@lists.php.net Subject: [PHP] file list and linking... Working on a script to list files in the folder of the file and all the subdirs in it ...but I have no idea how to make it so that each file that it brings up is linked (and with the actual http://..... instead of the /WWW/clients/ part) any help would be greatly appreciated. <?php $basedir = "/WWW/clients/tinseland.qpalzm.com/music/"; function listall($dir) { $dir_files = $dir_subdirs = array(); print( "<br><br><b>$dir</b><br>\n"); chdir($dir); $handle = @opendir($dir) or die( "Directory \"$dir\"not found."); while($entry = readdir($handle)) { if(is_dir($entry) && $entry != ".." && $entry != ".") { $dir_subdirs[] = $entry; } elseif($entry != ".." && $entry != ".") { $dir_files[] = $entry; } } sort($dir_files); sort($dir_subdirs); for($i=0; $i<count($dir_files); $i++) { print( "$dir_files[$i]<br>\n"); } for($i=0; $i<count($dir_subdirs); $i++) { listall( "$dir$dir_subdirs[$i]/"); } closedir($handle); } listall($basedir); ?> What I have so far is shown here: http://tinseland.qpalzm.com/music/music.php Thanks, Doug

« previous php.general (#31153) next »