其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$namafile 文件名,我是通过读取数据库中的图片名称
<?php
include_once('inc/db_mysql.inc.php');
include_once('inc/config.php');
include_once('kelas/fungsi.php');
global $picPath;
if (strstr($_SERVER[HTTP_USER_AGENT],"MSIE")) {
$lampiran = '';
} kalau tidak {
$lampiran = 'lampiran;';
}
$gambar = getInfo('newssp_gallery','id',$_GET['id']);
$namafile = $picPath.$gambar['namafile'];
if (!file_exists($namafile)) {
$namafile = $picPath."notexist.gif";
}
header("Kontrol Cache: tanpa penyimpanan, tanpa cache, harus divalidasi ulang"); // HTTP/1.1
header("Kontrol Cache: pasca-pemeriksaan=0, pra-pemeriksaan=0", false);
header("Pragma: tanpa cache"); // HTTP/1.0
header("Disposisi konten:".$attachment." filename=".$image['original']);
$ukuran = @ukuranfile($namafile);
header("Panjang Konten: $ukuran");
$fd = @fopen($nama file,rb);
$isi = @fread($fd,$ukuran);
@fclose ($fd);
echo $isi;
?>
使用的时候可以把在html文件里加上
<img src='showpic.php?id=xxx' width='50' height='50'>
showpic.php及上面的那个php文件,id=xxx是ID, lebar, lebar, tinggi, tinggi, tinggi, 例如,你要实现宽为50的缩略图,只要<img src='showpic.php? id=xxx' width='50'>这样就可以了