59bj.com - 北极网

  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
投递文章 经典文章 RSS订阅 网站公告:
搜索:
您的位置网站首页 > 网络编程 > PHP编程 > 浏览正文

PHP技术进阶:php用流方式制作缩略图

作者:佚名    来源:网络来源    点击数:   更新时间:2008年06月01 【字体:

其中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=http://www.chinaz.com/Program/PHP/showpic.php?id=xxx width=50 height=50>

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

Tags:PHP 技术 缩略图
责任编辑:

注册投稿

收藏本文到  >>>

北极网,中国网络之家
关于我们 - 联系我们 - 广告服务 - 站长工具 - 友情链接 - 网站地图 -网站留言 - 帮助中心