I'm trying to create a script that acts as a file manager for users to view/add files into their allowed directories. But there's sommin seriously wrong with the the reading of directories portion...what am i doing wrong?
The following is where the problem occurs. If there are no directories in the current directory then it executes fine, whereas if php tries to view a folder/add it to the array, it gives an error. How can I list both the directories and files found in the directory specified?
PHP Code:
<?php
$dir = "temp/temp2/";
$emptydirectory = true;
$PHP_SELF = "index.php";
$filecount = 0;
$filelist=array();
if (!is_dir($dir))
{
print "Directory does not exist";
return(false);
}
while (($file = readdir($dh)) !== false)
{
$fileinfo = pathinfo($file);
array_push($filelist,$file);
$filecount ++;
}
print "<form method=\"post\" enctype=\"multipart/form-data\" action=\"$PHP_SELF\" name=\"editfile\" onsubmit=\"return formCheck(this);\">";
// rest of form etc
?>