PHP/File Directory/filesize

Материал из Web эксперт
Перейти к: навигация, поиск

Determining File Size with filesize()

   <source lang="html4strict">

<? print "The size of test.txt is. "; print filesize( "test.txt" ); ?>

 </source>
   
  


filesize() function returns the size, in bytes.

   <source lang="html4strict">

Its syntax is: int filesize (string filename) <?

   $fs = filesize("data.txt");
   print "Pastry.txt is $fs bytes.";

?>

 </source>
   
  


filesize.php

   <source lang="html4strict">

<?php

  $file = "data.txt";
  $bytes = filesize("$file"); 
  echo "File ".basename($file)." is $bytes bytes, or ".round($bytes / 1024, 2)." kilobytes.";

?>

 </source>