时间:2021-07-01 10:21:17 帮助过:7人阅读
$obj = new finfo(FILEINFO_MIME_TYPE);
$type = $obj->file($file);
switch($type){
case 'image/gif': $img = imagecreatefromgif($file); break;
case 'image/jpeg': $img = imagecreatefromjpeg($file); break;
case 'image/png': $img = imagecreatefrompng($file); break;
default: return false;
}