1
    //Your Image
$imgSrc = $_GET['f'];
list($width, $height) = getimagesize($imgSrc);


list($root) = explode('httpdocs', __FILE__);
$root = $root.'httpdocs';
$savePath = $root.'/_m/chacheImages/';

$savePath = '../cacheImages/';

$imgName = basename($imgSrc);
list($imgName) = explode('.', $imgName);
$fileName = $savePath.$imgName.'.jpg';

if($width > 0 && $height > 0){

  $thumbSize = 100;
  $img_p = imagecreatetruecolor($width, $height);
  $img = imagecreatefrompng($imgSrc);
  imagecopyresampled($img_p, $img, -10, 0, 0, 10, $width+30, $height, ($width), ($height-20));

  //header('Content-type: image/png');
  imagejpeg($img_p, $fileName);
  imagedestroy($img_p);
}

我似乎无法让它工作。如果我在 imagejpeg 中删除 $fileName,它会正确显示图像。但它不会保存图像。我究竟做错了什么?

4

0 回答 0