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

您的位置:首頁技術(shù)文章
文章詳情頁

php用流方式制作縮略圖

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

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

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

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

<img src='http://www.baoyu77737.com/bcjs/showpic.php?id=xxx' height='50'>

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

標(biāo)簽: PHP
主站蜘蛛池模板: 平顶山市| 南涧| 邛崃市| 梧州市| 微山县| 上饶市| 班戈县| 岳普湖县| 阿拉善盟| 潮安县| 杭锦旗| 汶上县| 威海市| 英超| 瑞安市| 保山市| 邯郸县| 温宿县| 宜昌市| 阿拉善盟| 九龙县| 黑河市| 高雄市| 普兰县| 大荔县| 巫山县| 鹤庆县| 宁蒗| 西畴县| 策勒县| 台北市| 镇远县| 浦城县| 收藏| 德阳市| 寿阳县| 石棉县| 开原市| 兴文县| 云和县| 沈丘县|