Page 1 of 1

need opendir help

Posted: Sat Jul 31, 2010 10:16 pm
by dsick
the open dir needs to pass in a request of $_GET['dir'], so it would need to pull the value from

http://www.localhost.com/file.php?dir=dirname

the opendir function doesn't even recognize that

i want to open the directory based on the $_GET['dir']

Code: Select all


<?php
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo "<XML>";




$handle = opendir($_GET['dir']);
// define an array to hold the files
$files = array();


if ($handle) {

   while (false !== ($fname = readdir($handle))) {
      
      if (($fname != '.') && ($fname != '..') &&
          ($fname != basename($_SERVER['PHP_SELF']))) {
          $files[] = (is_dir( "./$fname" )) ? "(Dir) {$fname}" : $fname;
          $name = substr($fname, 0, strrpos($fname, '.'));
          
          echo "<Song>";
  
     
   
     echo "<songTitle>$name</songTitle>";
     echo "<Br/>";
     echo "<songArtist>$artistname</songArtist>";
     echo "<Br/>";
echo "</Song>";
          
     }
   }
   closedir($handle);
}




;
	   


echo "</XML>";


?>