php用流方式制作缩略图
时间:2008-05-28 来源:剑心通明
.Gyx271 { display:none; }
其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称 php程序员之家
phperz.com
global $picPath;
phperz.com
if (strstr($_SERVER[HTTP_USER_AGENT],"MSIE")) {
$attachment = '';
} else {
$attachment = ' atachment;';
}
phperz.com
$image = getInfo('newssp_gallery','id',$_GET['id']);
www.phperz.com
$filename = $picPath.$image['filename']; phperz.com
if (!file_exists($filename)) {
$filename = $picPath."notexist.gif";
}
www~phperz~com
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0 phperz~com
header("Content-disposition:".$attachment." filename=".$image['original']); phperz~com
$size = @filesize($filename); php程序员之家
header("Content-Length: $size");
www~phperz~com
$fd = @fopen($filename,rb);
$contents = @fread($fd,$size);
@fclose ($fd);
phperz~com
echo $contents;
?> phperz~com
使用的时候可以把在html文件里加上
phperz~com
phperz.com
showpic.php及上面的那个php文件,id=xxx是数据库里的记录ID,width是缩略图的宽,height是缩略图的高,请不要同时宽高都上,例如,你要实现宽为50的缩略图,只要这样就可以了
php程序员站
相关阅读 更多 +