打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

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

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

其中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‘>这样就可以了
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
php初学者应该学哪些
ecshop图片缩略图质量不清楚
推荐一些免费空间网站和提供商
php导出excel电子表格
conn.php
MySQL PHP 和 Perl快速配置-XAMPP安装包
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服