PHP上传图片时,如何判断上传的文件是否为可用的图片文件

mac2022-06-30  22

利用getimagesize函数:function isImage($filename){$types = '.gif|.jpeg|.png|.bmp';//定义检查的图片类型if(file_exists($filename)){$info = getimagesize($filename);$ext = image_type_to_extension($info['2']);return stripos($types,$ext);}else{return false;}}if(isImage('test.jpg')!==false){echo '是图片';}else{echo '不是';}

转载于:https://www.cnblogs.com/shaohuixia/p/5464687.html

相关资源:判断上传文件是否jpg图片
最新回复(0)