其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称
<?php
include_once ('inc/db_mysql.inc.php');
include_once ('inc/config.php');
include_once ('class/function.php');
global $picpath;
if (strstr($_server[http_user_agent],"msie")) {
$attachment = '';
} else {
$attachment = ' atachment;';
}
$image = getinfo('newssp_gallery','id',$_get['id']);
$filename = $picpath.$image['filename'];
if (!file_exists($filename)) {
$filename = $picpath."notexist.gif";
}
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
header("content-disposition:".$attachment." filename=".$image['original']);
$size = @filesize($filename);
header("content-length: $size");
$fd = @fopen($filename,rb);
$contents = @fread($fd,$size);
@fclose ($fd);
echo $contents;
?>
使用的时候可以把在html文件里加上
<img src='showpic.php?id=xxx' width='50' height='50'>
showpic.php及上面的那个php文件,id=xxx是数据库里的记录id,width是缩略图的宽,height是缩略图的高,请不要同时宽高都上,例如,你要实现宽为50的缩略图,只要<img src='showpic.php?id=xxx' width='50'>这样就可以了
新闻热点
疑难解答