Search code examples
phpfunctionfilesizestat

filesize() [function.filesize]: stat failed for LinqBridge.dll in


i write a script to list my file from Update directory with this option:

file-name file-hash file-size

why i get this error:

Warning: filesize() [function.filesize]: stat failed for LinqBridge.dll in      C:\xampp\htdocs\update.php on line 15

my php cod:

<?php
  if(isset($_GET['action']) and ($_GET['action']=="list"))
 {
    $myDirectory = opendir("./Update/");
    while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
 }
    closedir($myDirectory);
    $indexCount = count($dirArray);
    sort($dirArray);
   for($index=0; $index < $indexCount; $index++) {
    if (substr("$dirArray[$index]", 0, 1) != "."){
    echo $dirArray[$index]."&nbsp;";
    echo @hash_file('md5',$dirArray[$index])."&nbsp;";
    echo filesize($dirArray[$index])."&nbsp;";
}
 }
 }
  ?>

Solution

  • Your files in $dirArray are located in a different directory. You are reading them from "./Update/" thus when doing a filesize or filectime or filemtime or wahtever else, you need to prefix with "./Update/".

    echo filesize("./Update/".$dirArray[$index])."&nbsp;";