我有一个接收 id 并将图片发回的协议。现在我有问题如何发送只创建 .gif ?在这里请看一下我的代码
if($id!="")
{
........
$ext = substr( $picturename, strrpos($picturename, '.')+1 );
switch($ext)
{
case 'jpg':
$ext = 'jpeg';
break;
case 'jpeg':
$ext = 'jpeg';
break;
case 'png':
$ext = 'png';
break;
case 'gif':
$ext = 'gif';
break;
}
header('Content-Description: File Transfer');
header('Content-Type: image/'.$ext);
$file = "./images/".$picturename;
readfile($file);
//this work
}
else
{
// Create a 1x1 image
$im = imagecreatetruecolor(55, 30);
$trans = imagecolorallocate($im, 0, 0, 0);
// Make the background transparent
imagecolortransparent($im, $trans);
header('HTTP/1.1 403 Forbidden');
//How can I send .gif back with header ??
}