I want to show a carousel of image gallery on my php website (codeigniter 3.1 with jquery 3.3.1 and bootstrap 3). but when I check the file in the server, one of the file have filesize of 0. what method is best to make sure if the file can be shown properly? should I depend solely on the filesize? or is there another recommended method?
Asked
Active
Viewed 28 times
0
-
1If a file has size of 0 it means it has no data in it. Yes it would be OK to rely on filesize(). The other thing is to check if it is indeed an image file before you proceed to display it. – Joseph Jan 24 '22 at 08:02
-
oh ok.. I thought a reaallly small image would have very small file size that it might show 0 too.. – dapidmini Jan 24 '22 at 08:32
1 Answers
2
Checking the file size of the image is actually what you wanted. As mentioned by some answers to this question (PHP Detecting if source image url link leads to a "broken" image?), it's reliable to know whether the image is broken or not is by getting the file and checking its size.

K. Pradnyana
- 77
- 1
- 1
- 12