Browse Source

improve image type check

master
filesite 2 years ago
parent
commit
32d8336bec
  1. 9
      controller/ApiController.php

9
controller/ApiController.php

@ -610,14 +610,19 @@ Class ApiController extends Controller {
return ''; return '';
} }
return strtolower(array_pop($arr)); $suffix = array_pop($arr);
if (in_array($suffix, ['jpg', 'jpeg'])) {
$suffix = 'jpg';
}
return strtolower($suffix);
} }
//从文件类型中解析文件后缀 //从文件类型中解析文件后缀
protected function getSuffixFromFileType($fileType) { protected function getSuffixFromFileType($fileType) {
$arr = explode('/', $fileType); $arr = explode('/', $fileType);
if (count($arr) < 2) { if (count($arr) < 2) {
return ''; return $fileType;
} }
$suffix = array_pop($arr); $suffix = array_pop($arr);

Loading…
Cancel
Save