在foreach 循环中这行红色圈出来的部分报错 是什么问题呢
因为你选择的文件有一些扩展名不是图片类型的
if ($flag&&in_array($ext,$allowExt)) {
if (!getimagesize($fileInfo['tmp_name'])) {
$res['mes'] = $fileInfo['name'].'不是真实图片类型';
}
加上in_array($ext,$allowExt)就行了
list ( $dst_w, $dst_h, $dst_type ) = getimagesize ( 图片url)
参数$dst_type为图片类型 1:gif 2:jpg 3:png
完整判断代码
// 输出图片
list ( $dst_w, $dst_h, $dst_type ) = getimagesize ( $this->picPath );
switch ($dst_type) {
case 1 : // GIF
// header ( 'Content-Type: image/gif' );
imagegif ( $dst , $this->newPicPath) ;
break;
case 2 : // JPG
// header ( 'Content-Type: image/jpeg' );
$result = imagejpeg ( $dst , $this->newPicPath) ;
// imagejpeg ( $dst );
break;
case 3 : // PNG
// header ( 'Content-Type: image/png' );
$result = imagepng ( $dst , $this->newPicPath) ;
// imagepng ( $dst );
break;
default :
break;
}
imagedestroy ( $dst );