How to learn{find out} the size of a file on any web - server
The first way: to download and see.
The second way is described here.
That it to make, it is necessary to open a socket (to establish connection with the removed web - server). The socket is a file in which it is possible to write and read. Further (as in a file) it is necessary to write heading to a socket (HEAD filename...). The ambassador to count from a socket that will write to us. For the beginning deduce{remove} it on the screen that it was understandable what exactly to you return. In the answer of the server, that we count, there will be a lot of helpful information - type and OS of the server, date of updating and the size of a file, another information. Everything, that is necessary - to tear out the necessary number from the text and to display it .
<?
$fname = '/path-to-file/big-big-big.mpg ';
$fhost ='www.super-mega.ru ';
$x=0;
$fp = fsockopen ($fhost, 80, both $errno, and $errstr, 30) or die ("oblom");
fputs ($fp, " HEAD $fname HTTP/1.0\nHOST: $fhost\n\n ");
while (! feof ($fp)) $x. = fgets ($fp, 128);
fclose ($fp);
if (ereg (" Content-Length: ([0-9] +) ", $x, $size)) echo " the Size of a file $size [1] bytes ";
else echo " To define{determine} it is impossible ";
?>

|