views:

37

answers:

4

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?

+2  A: 

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

Stewie
yeah, true, i just noticed, thanks. i should have thought of it before hand, im such an idiot.
Macao
+1  A: 

You can't look up the filesize of a remote file like that. It is meant for looking at the filesize of local files.

For instance...

$imgsize = filesize( '/home/projects/site/1.jpg' );
BBonifield
A: 

filesize takes the name of the file as argument not a URL and it returns the size of the file in bytes. You can divide the return value with 1024 to get the size in KB.

codaddict
A: 

filesize() is the function to use. It might be failing because

  1. You're trying to get a web address & URL wrappers may not be turned on
  2. That URL isn't valid.

If you're trying to run filesize() on a local file, reference the file system path, not some web URL.

Pickle