I am trying to find a PHP function that will allow me to determine the file size of images uploaded. i.e. I want to block images over a certain size.
I tried using the getimagesize();
function but this only seem to give the width and height of an image.
I have enclosed below the array values returned from the getimagesize function. Unless i am mistaken, there is nothing in this array that relates to the actual file size
array(6) { [0]=> int(800) [1]=> int(800) [2]=> int(3) [3]=> string(24) "width="800" height="800"" ["bits"]=> int(music) ["mime"]=> string(9) "image/png" }
Do you need the filesize() function?
You're being deceived by the "image" part of your question. How do you determine the file size of a generic file? why would an image be different?
Since images are files too, you should use the filesize() function provided by PHP
This should work:
You can try code like this: