If a file is uploaded to the server, is there a way using PHP, to make sure that it\'s actually a picture and not just a file with a .jpg or .gif extension?
best way to check if file is an image
function is_image($path)
{
$a = getimagesize($path);
$image_type = $a[2];
if(in_array($image_type , array(IMAGETYPE_GIF , IMAGETYPE_JPEG ,IMAGETYPE_PNG , IMAGETYPE_BMP)))
{
return true;
}
return false;
}
more: http://www.binarytides.com/php-check-if-file-is-an-image/