server - How to Identify a File is image or not in PHP -


i have tried getimagesize() , finfo , getting mime type function. have noticed can not trust on these function observed it's fails in case image files. have better way identify file image or not. use case : have 1 file php code inside it. have saved file image extension. want block file getting uploaded.

try php's inbuilt method check image type,

int exif_imagetype ( string $filename ) 

this method returns false if file not valid image otherwise return integer pointing type of image.

also throws notice. may this.

if(@exif_imagetype($file)){      //valid image } else {      // invalid } 

Comments

Popular posts from this blog

c++ - CPP, 'X' button listener -

shared memory - gstreamer shmsrc and shmsink with h264 data -

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -