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
Post a Comment