Home
Home Page
Krossbrauzernoe alignment on the center (table height=100 %)
Lists a la MS Word
Features of links « upwards pages »
Tables and borders
We get rid from cellpadding and cellspacing
Optimum use MySQL
Competent job with files: exclusive blocking of files
How to learn{find out} the size of a file on any web - server
Regular expressions
Processing of lines in RNR
Creation of system of the account of visitings
Tracking a content on dynamic sites
CSS: advice{councils} and receptions, a part 2
CSS: advice{councils} and receptions, a part 1
Ten rules of a spelling of a safe code on PHP
About tags and metatags
Potential vulnerability of php-scripts
Removal{Distance} of a line from a file
The generator of passwords
Links
 

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 ";


?>