hi there,
I am using the below code while trying to access the directory structure. The code I took from the link above is,
PHP Code:
[COLOR="RoyalBlue"]function LoadFiles($dir,$filter="")
{
$Files = array();
$It = opendir($dir);
if (! $It)
die('Cannot list files for ' . $dir);
while ($Filename = readdir($It))
{
if ($Filename != '.' && $Filename != '..' )
{
if(is_dir($dir . $Filename))
{
$Files = array_merge($Files, LoadFiles($dir . $Filename.'/'));
}
else
if ($filter=="" || preg_match( $filter, $Filename ) )
{
$LastModified = filemtime($dir . $Filename);
$Files[] = array($dir .$Filename, $LastModified);
}
else
continue;
}
}
return $Files;
}
function DateCmp($a, $b)
{
return strnatcasecmp($a[1] , $b[1]) ;
}
function SortByDate(&$Files)
{
usort($Files, 'DateCmp');
}
$Files = LoadFiles("../../templates/images/data/communes/");
SortByDate($Files);
reset($Files);
while (list($k,$v) =each($Files))
{
?> - <?=$v[0]?> <?= date('Ymd h:i',$v[1])?></li><?
} [/COLOR]
where as I am just passing the following $path variable to funcation LoadFiles().
$sub = ($_GET['dir']);
$path = 'C:\Inetpub\wwwroot\reports\Backup\Backup Usage\';
$path = $path."$sub";
$Files = LoadFiles($path);
(i also tried plan path i.e $path = 'C:\Inetpub\wwwroot\reports\Backup\Backup Usage\'
But the program is giving me 'unexpected T_string error'. Does any one got an idea what this error would be reffering to ?
I will be great if some one could solve this, as it is realy urgent for me.
Regards,
Sameer.
Bookmarks