<?php
if (exif_imagetype("image.gif") != IMAGETYPE_GIF) {
echo "The picture is not a gif";
}
if (in_array(exif_imagetype("path/to/file"), array(IMAGETYPE_GIF , IMAGETYPE_JPEG ,IMAGETYPE_PNG , IMAGETYPE_BMP))) {
echo "This is a picture ";
}
?>
转自:PHP简单方法判断文件是否是图片 PHP best way to check if file is an image