我的程序使用以下代码与jpeg和gif图像完美配合。但是,当我尝试上传png和bmp文件时,图像无法正常上传。我做错了什么?
list($width,$height)=getimagesize($imagefile);
if($_FILES['image']['type']=="image/png"){$src=imagecreatefrompng($imagefile);$type="png";}
if($_FILES['image']['type']=="image/gif"){$src=imagecreatefromgif($imagefile);$type="gif";}
if($_FILES['image']['type']=="image/bmp"){$src=imagecreatefromwbmp($imagefile);$type="bmp";}
if($_FILES['image']['type']=="image/jpeg"){$src=imagecreatefromjpeg($imagefile);$type="jpeg";}
$orig_h=($height/$width)* $orig_w;
$tmp=imagecreatetruecolor($orig_w,$orig_h);
imagecopyresampled($tmp,$src,0,0,0,0,$orig_w,$orig_h,$width,$height);
imagejpeg($tmp,$folder.$filename,100);
if($type=="png"){imagepng($tmp,$folder.$filename,100);}
if($type=="gif"){imagegif($tmp,$folder.$filename,100);}
if($type=="bmp"){imagewbmp($tmp,$folder.$filename,100);}
if($type=="jpeg"){imagejpeg($tmp,$folder.$filename,100);}
imagedestroy($tmp);
imagedestroy($src);