久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

php用流方式制作縮略圖

瀏覽:117日期:2024-02-01 13:08:09

其中db_mysql.inc.php,config.php,function.php不是真正使用到的,關鍵是$filename 文件名,我是通過讀取數據庫中的圖片名稱

<?phpinclude_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.1header('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='http://m.baoyu77737.com/bcjs/showpic.php?id=xxx' height='50'>

showpic.php及上面的那個php文件,id=xxx是數據庫里的記錄ID,width是縮略圖的寬,height是縮略圖的高,請不要同時寬高都上,例如,你要實現寬為50的縮略圖,只要<img src='http://m.baoyu77737.com/bcjs/showpic.php?id=xxx' width='50'>這樣就可以了

標簽: PHP
主站蜘蛛池模板: 乐陵市| 上杭县| 安福县| 通山县| 赤壁市| 仙居县| 托克逊县| 肃北| 肥城市| 依兰县| 广南县| 平果县| 浪卡子县| 虞城县| 龙江县| 简阳市| 外汇| 新余市| 宜兰市| 安福县| 湘潭县| 余庆县| 江华| 铁岭市| 灌云县| 全州县| 色达县| 石渠县| 新建县| 浙江省| 容城县| 河西区| 白朗县| 合阳县| 慈利县| 铁力市| 西昌市| 肃宁县| 玉山县| 旅游| 错那县|