php get the KB size of an image

Macao picture Macao · Sep 27, 2010 · Viewed 23.7k times · Source

i've been googleing but all i get is getimagesize and filesize.
getimagesize dosent get the KB size just width and height which is not what im looking for.
filesize give me the message Warning: filesize() [function.filesize]: stat failed for
the file in question is 51kb .jpg file

$imgsize=filesize("http://localhost/projects/site/schwe/user/1/1.jpg");

does not work,

how do i accomplish this?

Answer

Stewie picture Stewie · Sep 27, 2010

You cannot get file size of remote elements, either give a relative path on your system OR do a file_get_contents() to get contents first . Thus, instead of http:// , do a filesize('/path/to/local/system') . Make sure its readable by php process