Images and script are hosted on the same account (one site), but we know only the URL of the image.
$image = \"http://example.com/images/full-1091.jpg\"
<?php
$contents=file_get_contents("http://site.com/images/full-1091.jpg");
// var_dump($contents);
// $fp =fopen("1.jpeg","w");
file_put_contents("1.jpeg",$contents);
$size= filesize("1.jpeg");
echo $size."in Bytes";
?>
Check this it can work for you
Please Note:
The result of filesize() function are cached! Use clearstatcache() to clear the cache...
source: http://www.w3schools.com/php/func_filesystem_filesize.asp
echo filesize($_SERVER['DOCUMENT_ROOT']."/images/full-1091.jpg");
note that http://site.com/images/full-1091.jpg
is not a file
as for the formatted output ("156,8 Kbytes" or "20,1 Mbytes") try to help yourself and use search. There is a ton of answers to this question already.
Use filesize function like this:
echo filesize($filename) . ' bytes';
You can also format the unit of the size with this function:
function format_size($size) {
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
if ($size == 0) { return('n/a'); } else {
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); }
}
Images and script hosted on the same account (one site).
Then don't use a URL: Use the direct file path and filesize().