Hello, I'm programming a small CMS for my website and I wanted to put up a small navigation system so I can easily browse through the files located on in my scripts local directories.
I'm pretty new to screwing around with the file system, but I kind of got it down. The problem is whenever I get to a new sub directory under the root I get warning msgs (I know I can disable them in my php.ini, but I REALLY hate even the smallest bugs.):
Warning: stat failed for file.gif (errno=2 - No such file or directory) in c:\program files\apache group\apache\htdocs\tinysite\admin\files.php on line 44
Warning: stat failed for file.gif (errno=2 - No such file or directory) in c:\program files\apache group\apache\htdocs\tinysite\admin\files.php on line 45
Now, I if I goto the root and then goto a new subdirectory I get this:
Warning: OpenDir: Invalid argument (errno 22) in c:\program files\apache group\apache\htdocs\tinysite\admin\files.php on line 24
Fatal error: Call to a member function on a non-object in c:\program files\apache group\apache\htdocs\tinysite\admin\files.php on line 26
I think I have an idea as to what the problem is, but I have no idea how to explain or solve it. Please help, I've gotten too far to just up and quit!!!
Here is the complete code:
if(!isset($directory)){ $directory = "./"; }
$d = dir($directory);
while ($entry = $d->read()){
$extArray = explode(".", $entry);
$extCount = count($extArray);
$ext = end($extArray);
if($extCount == 1){
$icon = "<img src='./images/folder.gif'>";
$entry = "<a href='./files.php?directory=$entry'>$entry</a>";
}else{
if($entry == "."){
$icon = "-";
$entry = "[ <a href='./files.php?directory=.'>up one level</a> ]";
}elseif($entry == ".."){
$icon = "-";
$entry = "[ <a href='./files.php?directory=..'>up to root</a> ]";
}else{
$icon = "<img src='./images/file.gif'>";
if(!is_dir($entry)){
$fsize = number_format(filesize($entry));
$ftime = date("m-d-y h:i a", filemtime($entry));
}else{
$fsize = "-";
$ftime = "-";
}
$options = "bleh?";
}
}
$rowColor = altcolor();
$fileList .= "
<tr $rowColor>
<td align='center' valign='top' width='5%'>$icon</td>
<td>$entry</td>
<td align='center' width='10%'><font color='green'>$fsize</font></td>
<td align='center' width='20%'><i>$ftime</i></td>
<td align='center' width='5%'>$options</td>
</tr>
";
}
$d->close();
All I really want is to be able to use this code to navigate through my account's file system and pass the actual PATH to a file as a variable through forms and links and such.
Please help.... please. 🙁