faqts : Computers : Programming : Languages : PHP : Common Problems : Files

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 16 people (63%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I check the filesize of a file on another server?

Dec 22nd, 2000 13:18
Ben Udall, Martin Akesson, Yvo SChaap, http://www.php.net/manual/function.fopen.php


It all depends on how you're accessing that other sever.  A file on a 
http server can be accessed with php, and the file size derived from 
that.  For example:
$fp = fopen('http://www.php.net', 'r');
$size = 0;
if ($fp) {
   while (!feof($fp))
      $size += strlen(fread($fp, 4096));
   fclose($fp);
}
echo 'file size is ' . $size  . ' bytes';
More details can be found in the php documentation for fopen() 
http://www.php.net/manual/function.fopen.php