RSS订阅
PHP程序员站--WWW.PHPERZ.COM  
网站地图
高级搜索
收藏本站

 当前位置:主页 >> PHP基础 >> 基础文章 >> 文章内容
php用流方式制作缩略图
[收藏此页[打印本页]   
来源:互联网  作者:网络转载  发布时间:2007-12-23

其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称 phperz.com

<?php
include_once ('inc/db_mysql.inc.php');
include_once ('inc/config.php');
include_once ('class/function.php'); www.phperz.com

global $picPath;

www~phperz~com

if (strstr($_SERVER[HTTP_USER_AGENT],"MSIE")) {
  $attachment = '';
} else {
  $attachment = ' atachment;';
}

php程序员之家

$image = getInfo('newssp_gallery','id',$_GET['id']);

www~phperz~com

$filename = $picPath.$image['filename']; php程序员站

if (!file_exists($filename)) {
  $filename = $picPath."notexist.gif";
} php程序员站

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");

php程序员之家

$fd = @fopen($filename,rb);
$contents = @fread($fd,$size);
@fclose ($fd); phperz.com

echo $contents;
?>

www~phperz~com

使用的时候可以把在html文件里加上 phperz.com

<img src='showpic.php?id=xxx' width='50' height='50'> phperz.com

showpic.php及上面的那个php文件,id=xxx是数据库里的记录ID,width是缩略图的宽,height是缩略图的高,请不要同时宽高都上,例如,你要实现宽为50的缩略图,只要<img src='showpic.php?id=xxx' width='50'>这样就可以了 php程序员站


 
 相关文章
 
发表评论
全部评论(0条)
 
 站内搜索
 热门搜索 基础  mysql  url  adodb
高级搜索 网站地图 站长工具 IP查询 收藏本站
 热点文章
 随机推荐
网站首页 | 网站地图 | 高级搜索 | RSS订阅
PHP程序员站 Copyright © 2007,PHPERZ.COM All Rights Reserved 粤ICP备07503606号 联系站长