日期:2014-05-17 浏览次数:20455 次
//创建一个真彩画布
$image = imagecreatetruecolor(400,190);
//背景创建颜色
$green = imagecolorallocate($image,255,255,255);
//填充画布颜色
imagefill($image,0,0,$green);
//输出图片
header("Content-Type: image/jpeg");
imagejpeg($image);
//销毁资源
imagedestroy($image);
<a href="imagedown.php?filename=image.php"><img src="image.php" /></a>
if(isset($_GET['filename'])){
????????//var_dump(getimagesize($_GET['filename']));
????????download($_GET['filename']);
????}
????function download($fileName){
????????header("Content-Type: image/jpeg");
????????header('Content-Disposition: attachment; filename="'.$fileName.'"');
????????header('Content-Length: '.filesize($fileName));
????????readfile($fileName);
????}
download('x.jpg');
function image() {
//创建一个真彩画布
$image = imagecreatetruecolor(400,190);
//背景创建颜色
$green = imagecolorallocate($image,255,255,0);
//填充画布颜色
imagefill($image,0,0,$green);
//输出图片
//header("Content-Type: image/jpeg");
imagejpeg($image);
//销毁资源
imagedestroy($image);
}
function download($fileName){
ob_start();
image();
$s = ob_get_clean();
header("Content-Type: image/jpeg");
header('Content-Disposition: attachment; filename="'.$fileName.'"');
header('Content-Length: '.strlen($s));
echo $s;
}