Last active
April 8, 2018 17:07
-
-
Save lenivene/17b7796234a4b8f1715cee85a4ead112 to your computer and use it in GitHub Desktop.
Check file is image by php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Required PHP version >= 4.2.0 | |
function is_image( $filename ){ | |
$getImageSize = getimagesize( $filename ); | |
$image_type = $getImageSize[2]; | |
if( in_array( $image_type, array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP ) ) ) | |
return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment