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

首頁(yè) > 開(kāi)發(fā) > PHP > 正文

php用流方式制作縮略圖

2024-05-04 23:04:42
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友


其中db_mysql.inc.php,config.php,function.php不是真正使用到的,關(guān)鍵是$filename 文件名,我是通過(guò)讀取數(shù)據(jù)庫(kù)中的圖片名稱

<?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;
?>

使用的時(shí)候可以把在html文件里加上

<img src='showpic.php?id=xxx' width='50' height='50'>

showpic.php及上面的那個(gè)php文件,id=xxx是數(shù)據(jù)庫(kù)里的記錄id,width是縮略圖的寬,height是縮略圖的高,請(qǐng)不要同時(shí)寬高都上,例如,你要實(shí)現(xiàn)寬為50的縮略圖,只要<img src='showpic.php?id=xxx' width='50'>這樣就可以了

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 辰溪县| 图木舒克市| 磴口县| 尚义县| 白山市| 邯郸县| 宜春市| 民勤县| 克什克腾旗| 荆州市| 涟源市| 瓦房店市| 肇庆市| 五常市| 梨树县| 剑河县| 温宿县| 勐海县| 佳木斯市| 双牌县| 马鞍山市| 玉田县| 肥西县| 册亨县| 涡阳县| 十堰市| 会泽县| 姜堰市| 沂水县| 黄石市| 临安市| 农安县| 理塘县| 上思县| 阳西县| 许昌市| 渝中区| 象州县| 开江县| 观塘区| 郁南县|