php用流方式制作缩略图
2005-06-19 16:38
274 查看
其中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
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用流方式制作缩略图
- 【PHP缩略图类】手机照片不能生成缩略图问题以及解决方式
- PHP制作图片缩略图、加水印、加字体
- php实现常见图片格式的水印和缩略图制作(面向对象)
- PHP使用GD函数库制作缩略图+保存本地
- php、js、java的正则替换文本方式制作模板内容输出
- PHP缩略图生成和图片水印制作
- PHP ThinkPHP 上传文件(图片),制作缩略图
- php实现常见图片格式的水印和缩略图制作(面向对象)
- php制作缩略图
- 教你用php制作一个缩略图教程
- PHP ThinkPHP ,上传文件(图片),制作缩略图,批量上传文件
- PHP根据图片制作缩略图
- php 缩略图封装类 制作缩略图
- 如何用PHP制作“饼图”函数?
- php 通过网页的方式备份和还原mysql数据库
- 动态网页制作技术PHP的变量类型
- PHP动态网站制作中关于文件操作的疑难问答
- php绘图技术制作验证码
- php中三种数据库的连接方式