国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP進階技巧:php用流方式制作縮略圖

2024-05-04 21:51:43
字體:
來源:轉載
供稿:網友

其中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'>這樣就可以了

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 常宁市| 巴楚县| 个旧市| 二连浩特市| 洛浦县| 宜川县| 鄂尔多斯市| 临江市| 凌源市| 丽水市| 正安县| 湖南省| 贡山| 探索| 黔西县| 垣曲县| 屯门区| 临泽县| 新乡县| 汪清县| 卓尼县| 巴林左旗| 磴口县| 赣州市| 伊吾县| 鄢陵县| 垣曲县| 安新县| 克什克腾旗| 渝中区| 武汉市| 晋江市| 手游| 丰原市| 博乐市| 罗定市| 科技| 林芝县| 渭南市| 新疆| 江北区|