php - how do i get remote image filesize? -
i trying remote image file size.
but getting error: "warning: filesize(): stat failed http://mfastore.com/_store/user_data/9fc8022_310/c/hydrangeas.jpg unknown file size "
this code trying image size in mb
$res= formatfilebytes("http://mfastore.com/_store/user_data/9fc8022_310/c/hydrangeas.jpg","mb"); echo $res; function formatfilebytes($file, $type) { switch($type){ case "kb": $filesize = filesize($file) * .0009765625; // bytes kb break; case "mb": $filesize = (filesize($file) * .0009765625) * .0009765625; // bytes mb break; case "gb": $filesize = ((filesize($file) * .0009765625) * .0009765625) * .0009765625; // bytes gb break; } if($filesize <= 0){ homecoming $filesize = 'unknown file size';} else{return round($filesize, 2).' '.$type;} }
help me please. thanks
try
$image_header = get_headers("http://mfastore.com/_store/user_data/9fc8022_310/c/hydrangeas.jpg", true); $size = $image_header["content-length"];
php
No comments:
Post a Comment