image_small.php看起來是這樣的:爲什麼這個imagepng不工作?
<?php
$id = (isset($_GET['im'])) ? $_GET['im'] : 0;
//fetch the image from database
$query='SELECT image_small FROM hr_employee WHERE id='.$id;
$result = pg_query($dbconn, $query) or die('Query failed: ' . pg_last_error());
$raw = pg_fetch_row ($result ,0)
$img=$raw['image_small'];
header("Content-Type: image/png");
if(!file_exists($cachefile)) {
imagepng($img, $cachefile);
imagedestroy($img);
}
$fp = fopen($cachefile, 'rb');
fpassthru($fp);
exit;
?>
我得到以下錯誤:
imagepng()預計參數1是資源,字符串中給定
它似乎標題(「Content-Type:image/png」);不按預期工作。你可以刪除這條線,看看是否有其他字符? – bksi
您確定GD已激活嗎? –
是的,GD根據phpinfo() –