Autor Zpráva
juraj
Profil
Zdravím
ako mám zobraziť počet súborov k prislušnému adresáru?
<?  $count =0;
function showDir($dir, $depth=0)
{
  if(!is_dir($dir)){
    die("not a directory");
  }
  
  $od = opendir($dir);

  while(($file = readdir($od)) !== false){
  
    if($file != "." && $file != "..")
    {
      if(is_dir("$dir/$file"))
      {
        echo "<tr><td>";

        echo str_repeat("  ", $depth) . " [$file] ";//adresare

    
        echo "</td></tr>";
        showDir("$dir/$file", ($depth + 1));
      }
      else
      {
        echo '<tr>     <td>';      
        echo str_repeat("  ",$depth) . " $file ";
        echo "</td><td>";
        echo ceil(filesize("$dir/$file")/1000)." KB";$count++;echo $count;    //subory

        echo "</td> </tr>";    
     }

    }
    
   }
           echo "</td> $count</tr>";
      // echo $count;
}
?>
<table border=1>
  <tr>
    <th>Directory/File Name</th>
    <th>Size</th>
  </tr>
<?
showDir("upload/");
?>
</table>
tiso
Profil
Pre začiatok si ten $count =0; z riadku 1 si daj až do tej funkcie, napríklad na riadok 9

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0