php 判断图片文件的真实类型
/****检测文件的真实类型**@paramstring$srcPath文件路径**@returnstring$realType文件真实类型**/$imgurl='https://cache.yisu.com/upload/information/20200310/52/109905.jpg';echofile_type_detect($imgurl);functionfile_type_detect($srcPath){$types=array(6677=>'bmp',7173=>'gif',7368=>'mp3',13780=>'png',255216=>'jpg',);$curl_obj=newcURL(false);$binary=$curl_obj->get($srcPath);//$binary=file_get_contents($srcPath);$bytes=substr($binary,0,2);$head=@unpack('C2char',$bytes);$typeCode=intval($head['char1'].$head['char2']);$realType=isset($types[$typeCode])?$types[$typeCode]:$typeCode;return$realType;}
判断文件的真实类型
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。