我正在尝试编写一个PHP文件mamanger,当我从"."更改导演时.到"../uploads/",filesize给了我这个错误:
警告:filesize()[function.filesize]:第83行/f5/jb-cms-testing/public/edit/files.php中zipped-file.zip的stat失败
第83行print(filesize($dirArray[$index]));(我知道这单独没用,当我粘贴它时,行号就会关闭)
它准确地列出了文件名,但由于某种原因没有列出大小.
这是完整的脚本:
// 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=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</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=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
print("<td>");
print(filesize($dirArray[$index]));
print("</td>");
print("</TR>\n");
}
}
print("</TABLE>\n");
Run Code Online (Sandbox Code Playgroud)
您正在打开../uploads/文件扫描文件夹,但检查当前工作目录中的filesize.
这应该是有帮助的:
print(filesize( '../uploads/' . $dirArray[$index]));
Run Code Online (Sandbox Code Playgroud)
这同样适用于您的链接,他们需要路径修正才能工作.