09-20-2007, 03:17 PM
|
#2 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 1,587
Thanks: 72
|
Sometimes the remote server will return you the Content-Length in the HTTP header. However, failing that, the way I would do it is:
PHP Code:
$szFile = file_get_contents('http://www.google.co.uk/intl/en_uk/images/logo.gif'); echo round(strlen($szFile) / 1024, 2) . 'KB';
This is assuming that all the characters are 1 byte a piece. 2 byte characters, such as Japanese characters, will give a bad reading, but you should be fine.
Needless to say that the Content-Length in the header is the way forward because the file doesn't need to be downloaded first - this is fine though with smallish files.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|