Can you tell me how to display the filesize of an image in kilobytes(kb). I will be using this code more than once, like 10 times on one page. Can you help me? 😕
There is a fileisze function in PHP. I think it returns the size in bytes, so just divide by 1024 to get the number in kb.
Diego
I don't want to see the size in bytes, but I don't want to use a calculator to find it out by dividing by 1024, so how would you make it display on the page? What would you put in the command? Any replies would be helpful, thanks.
Why get a calculator? Use PHP to do the work for you...
print filesize($filename) / 1024;
will print the filesize in kb.
Can you give me an example script? I'm new, and would like to know how to do it properly, thanks.
Ok, I found out a way to do it, and now all I need is to find out a way to limit the decimals. I want it to be like 3.76 or something like that. So what I'm saying is that I want it to stop after two(2) decimal places. Any help is appreciated.
Check out the round function, or the number_format function.
Ok, now is there a way to get the filesize of an image that is from a different website, i.e. http://www.host.com/~abc/pic.jpg. And you're putting the code on a different website, i.e. http://www.domain.com. So on domain.com, can you get the filesize of an image from an other website?
Does anyone know if you can do that, what I listed above, anyone? And Diego25, thanks for all your help.
Bump