0

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;";
}
 }
 }
  ?>
user1433591
  • 1
  • 1
  • 1
  • 5

1 Answers1

2

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;";
Mathieu Dumoulin
  • 12,126
  • 7
  • 43
  • 71
  • thank you worked. and other question: may file name in my host is Launcher[dot]exe but i want in echo its showed in real name like that:Launcher.exe can id do? – user1433591 Jun 21 '12 at 19:20
  • I didn't understand your message, please rephrase it and check your english, it's unreadable right now... – Mathieu Dumoulin Jun 21 '12 at 19:24
  • i have some file in multiple format like as .exe & .dll & .txt but for some reason i changed the format .exe to [dot]exe and in this script result(echo) the [dot]exe not showed as .exe i want it showed like .exe not [dot]exe. – user1433591 Jun 21 '12 at 19:31
  • i did that: ** if (substr("$dirArray[$index]", 0, 1) != "."){ $text = explode('[dot]',$dirArray[$index]); echo $text[0]; if(@$text[1]!="") echo ".".$text[1]; echo @hash_file('md5',$dirArray[$index])." "; echo filesize("./Update/".$dirArray[$index])." "; ** but now the file hash not showed?!! – user1433591 Jun 21 '12 at 19:47
  • echo str_replace('[dot]', '.', $dirArray[$index]) – Mathieu Dumoulin Jun 21 '12 at 19:48
  • i used your code: str_replace('[dot]', '.', $dirArray[$index]) and its worked but the file hash not showed?! – user1433591 Jun 21 '12 at 19:54
  • Look, our job is not to code for you, you need tounderstand what you want to achieve and understand what you are doing or else you'll never make it out. Try to understand your code, clean it up, test up stuff and move on. – Mathieu Dumoulin Jun 21 '12 at 19:56