PHP:exif_imagetype()无法正常工作? [英] PHP: exif_imagetype() not working?
本文介绍了PHP:exif_imagetype()无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个扩展程序检查器:
I have this extension checker:
$upload_name = "file";
$max_file_size_in_bytes = 8388608;
$extension_whitelist = array("jpg", "gif", "png", "jpeg");
/* checking extensions */
$path_info = pathinfo($_FILES[$upload_name]['name']);
$file_extension = $path_info["extension"];
$is_valid_extension = false;
foreach ($extension_whitelist as $extension) {
if (strcasecmp($file_extension, $extension) == 0) {
$is_valid_extension = true;
break;
}
}
if (!$is_valid_extension) {
echo "{";
echo "error: 'ext not allowed!'\n";
echo "}";
exit(0);
}
然后我添加了这个:
if (exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_GIF
OR exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_JPEG
OR exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_PNG) {
echo "{";
echo "error: 'This is no photo..'\n";
echo "}";
exit(0);
}
将其添加到imageupload函数后,该函数将立即停止工作.我没有任何错误,甚至没有我自己给自己这不是照片"的错误,这可能是什么问题?
As soon when I added this to my imageupload function, the function stops working. I dont get any errors, not even the one i made myself "this is no photo", what could be wrong?
只需与我的房东确认.它们支持功能exif_imagetype()
Just checked with my host. They support the function exif_imagetype()
推荐答案
以下是开关用法的示例:
Here is the example with the switch usage:
switch(exif_imagetype($_FILES[$upload_name]['name'])) {
case IMAGETYPE_GIF:
case IMAGETYPE_JPEG:
case IMAGETYPE_PNG:
break;
default:
echo "{";
echo "error: 'This is no photo..'\n";
echo "}";
exit(0);
}
您的脚本也可以使用,但是您必须在条件之间加上AND:
Your script can be used too, but you have to put AND between conditions:
if (exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_GIF
AND exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_JPEG
AND exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_PNG) {
echo "{";
echo "error: 'This is no photo..'\n";
echo "}";
exit(0);
}
这篇关于PHP:exif_imagetype()无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文