Problems with scanning a dir.
Posted: Sun Oct 12, 2003 10:19 am
Having trouble with this:
Generally speaking it works fine... but rather than separating files and directories, it prints all files and directories as if they were both files.
No distinction whatsoever...
Any idea what the problem might be?
Code: Select all
function seek_files()
{
global $SQL;
global $conf;
global $error;
// Let's get to scanning the directory...
if ( is_dir($this->upload_folder) )
{
if ($handle = opendir($this->upload_folder))
{
while (($files = readdir($handle)) !== false)
{
if ($files != ".." && $files != ".")
{
if ( is_dir($files) )
{
$direc[] = $files;
}
else
{
$file[] = $files;
}
}
}
// Sort and print files and directories.
if ( is_array($direc) )
{
sort ($direc);
foreach ($direc as $dir)
{
echo "<b>" .$dir. "</b><BR>";
}
}
elseif ( is_array($file) )
{
sort ($file);
foreach($file as $fil)
{
echo "<i>" . $fil . "</i><BR>";
}
}
}
else
{
$error -> print_error("bad_read");
}
}
else
{
$error -> print_error("no_dir");
}
}No distinction whatsoever...
Any idea what the problem might be?