Im having some trouble with some code that lists the content of a directory. at the moment it is supose to list the name of the file, the type and the file size. the code is displaying the file name fine but not the File Type or File Size. im getting error "Warning: filetype() [function.filetype]: Lstat failed for Signiture.jpg in C:\xampp\htdocs\Login\dean\index.php on line 62"
it works if i list the files in the same directory as this php code but not if i list files in a sub directory e.g $username/Uploads
Here is the code im using
PHP Code:<?php
// open this directory
$myDirectory = opendir("./Uploads/");
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=0 cellpadding=5 cellspacing=15 class=whitelinks>\n");
print("<TR><TH>File Name</TH><th>File Type</th><th>File Size</th></TR>\n");
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
print("<TR><TD><a href=\"./Uploads/$dirArray[$index]\">$dirArray[$index]</a></td>");
print("<td>");
print(filetype($dirArray[$index]));
print("</td>");
print("<td>");
print(filesize($dirArray[$index]));
print("</td>");
print("</TR>\n");
}
}
print("</TABLE>\n");
?>



Reply With Quote


Bookmarks