Toon posts:

[php] filesize() foutje ???

Pagina: 1
Acties:
  • 39 views sinds 30-01-2008

Verwijderd

Topicstarter
<html>
<body>
<table width="100%">
<?php
$handle = opendir("docs");
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$fs = filesize($file);
echo "<tr><td>$file</td><td>$fs</td></tr>\n";
}
}
closedir($handle);
?>
</table>
</body>
</html>

Oke, dit is dus het scrippie. Wat ik ook doe, hij geeft de foutmelding:
Warning: stat failed for probeg (errno=2 - No such file or directory) in c:\blaat\test.php on line 10

Maar, als ik een . (punt) invul bij 'opendir', dan laat 'ie wel alles goed zien, zonder enige fout.

By the way, zoals je misschien is opgevallen draai ik dit scriptje onder Windows. Hmmz, ik zag net dat het onder Unix/Linux ook zo is... hmpf!

'k Heb al van alles geprobeerd voor de dir:
docs
docs/
./docs
./docs/
.docs (?? tja, moest wat proberen ??)
etc...

Iemand een oplossing??

  • Nielsz
  • Registratie: Maart 2001
  • Niet online
filesize("docs".$file);

Athans, dat denk ik :)

Verwijderd

Topicstarter
Hmm, werkt helaas ook niet...

Dit werkt dus wél als ik een . (punt) invul. Dan laat 'ie keurig zien hoe groot het bestand is.

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Nooit aan gedacht, dat als je een directory uitleest, en dan vervolgens de bestand uit die directory probeert te openen, dat je dan ook de directory ervoor moet plakken om daadwerkelijk naar het goede bestand te wijzen :?

Redelijk triviaal, hoor, dit

edit:

PHP:
1
2
3
4
5
6
7
8
9
10
11
$dirname = './docs';
$dd = opendir ( $dirname );
echo "<pre>";
while ( $fn = readdir ( $dd ) ) {
   $path = $dirname . '/' . $fn;

   if ( !is_dir ( $path ) ) {
      echo "$fn: " . filesize ( $path ) . "\n";
   }
}
echo "</pre>";

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Dit topic is gesloten.