PHP进阶技巧:php用流方式制作缩略图_PHP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:用PHP来实现页面GZIP的压缩输出教程
GZIP(GNU-ZIP)是一种压缩技术。经过GZIP压缩后页面大小可以变为原来的30%甚至更小。这样用户浏览的时候就会感觉很爽很愉快! 要实现GZIP压缩页面需要浏览器和服务器共同支持,实际上就是服务

其中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'>这样就可以了

分享:用php odbc access数据库来操作函数
前些天下载了adodb,想用adodb连access数据库,后来连是连上了,不过不能更新和插入记录,也不知道为什么到现在还没人给我回答那个苦恼的问题,后来就放弃了adodb,使用php自己的odbc,但是使用

来源:模板无忧//所属分类:PHP教程/更新时间:2008-08-22
相关PHP教程