Mmmh.. I think what 555sandy wanted, is to determine the size of a remote file that is not sitting on his/her own server.
The following code works. However, not all servers send the optional "Content-length", and if they don't then it doesn't work. In that case the file would actually be read until the end. So it would be a good idea to limit the amount of data that gets read.
Anyway:
$domain = "www.phpbuilder.com"; #where the file is located
$file = "/images/new-logo.gif"; #path to the file
$host = "www.example.com"; # your own domain
$http = "GET ".$file." HTTP/1.0\r\nHost: ".$host."\r\n\r\n";
$fp = fsockopen ($domain, 80, $errno, $errstr, 30);
if (!$fp) { #connection can't be etsablished
echo "$errstr ($errno)<br>\n"; #error
}
else { #connection is OK
fputs ($fp, $http); #send http request
while (!feof($fp)){ # read until end of reply
$chunk= fgets ($fp,128); #get a chunk of the reply
if (strpos($chunk, "ength:")) # "Content-length:" (L/l)
{
$size = explode (':', $chunk); #split up at ":"
echo "The file has a size of $size[1] bytes<br>";
break; # task completed, don't read completely
} #end if
} #end while
fclose ($fp); #close connection when finished
} #end else
# based on php-manual example for fsockopen
Hope this helps,
Matthias