php 图片下载程序

作者:袖梨 2022-07-02

function displayimg($image)
 {
  $image = './upload/'.imgdecode($image);
  //echo $image;exit;
  if (file_exists($image))
  {
   $info = getimagesize($image);
   header("Content-type:$info[mime]");
   switch ($info[2])
   {
    case 1:  $cimage = imagecreatefromgif($image);
       imagegif($cimage);
       imagedestroy($cimage);
       break;
    case 2:  $cimage = imagecreatefromjpeg($image);
       imagejpeg($cimage);
       imagedestroy($cimage);
       break;
    case 3:  $cimage = imagecreatefrompng($image);
       imagepng($cimage);
       imagedestroy($cimage);
       break;
    case 6:  $cimage = imagecreatefromwbmp($image);
       imagewbmp($cimage);
       imagedestroy($cimage);
       break;
   }
   echo $simage;
  }
  else
  {
   header("HTTP/1.0 404 Not Found");
  }
 }

相关文章

精彩推荐