I can't open sub directory in php

     

I am trying to open a sub folder when user clicked on main directory url link. It does not either show any errors or content.


Here is my php code to open main folder which is working fine.


$loc = 'C:/Apache24/htdocs/www.test.in/stRec';  if (is_dir($loc)){   if ($dh = opendir($loc)){   while (($file = readdir($dh)) !== false){    echo''.$file.'';   }   }  }  

Code to open sub directory which shows no content.


if(isset($_GET['dir'])) {  $dir = $_GET['dir'];  $loc = 'C:/Apache24/htdocs/www.test.in/stRec'.$dir;  if (is_dir($loc)){   if ($dh = opendir($loc)){   while (($file = readdir($dh)) !== false){   echo $file;   }   }   }  }  
  
"
answer1
  
  
  

C:/Apache24/htdocs/www.test.in/stRec'.$dir

  

path separator on windows is ""



edit:


To get more details:


if (!isset($_GET['dir'])) {   die('dir not set');  }
$dir = $_GET['dir'];  $loc = 'C:whateverpath' . $dir;
if (!is_dir($loc)) {   die('not a dir');  }
if ($handle = opendir($loc)) {   while (false !== ($entry = readdir($handle))) {   echo "$entry ";   }   closedir($handle);  }