0
进出口试图确定图像的MIME类型:检查图像的MIME类型
$image = $_FILES['image']; //code shortened
function determineImage($imageResource){
$errors = array();
$types = array('gif' => IMAGETYPE_GIF,
'jpeg' => IMAGETYPE_JPEG,
'png' => IMAGETYPE_PNG,
'bmp' => IMAGETYPE_BMP);
if (!in_array(exif_imagetype($imageResource['tmp_name']), $types)) {
$errors[] = 'Cannot determine mime type';
}
if ($imageResource['type'] !== 'image/gif' ||
$imageResource['type'] !== 'image/jpeg' ||
$imageResource['type'] !== 'image/pjpeg' ||
$imageResource['type'] !== 'image/png'){
$errors[] = 'Again cannot determine type';
}
return $errors;
}
我使用
var_dump(determineImage($image));
此回头率阵列(1){[0] = >串(27) “同样不能确定类型”}
然而这样的:
echo $image['type'];
刚刚返回:
image/png
我也得到了使用error_reporting(E_ALL)开启。任何人都可以弄清楚问题是什么,我犯了一个愚蠢的错误?
的代码被缩短的方式(支票没有意义可言)
,我编辑别人的代码。谢谢这是AND。现在应该睡觉了。 –
xD你需要一个良好的睡眠 – skyline26