用流方式制作缩略图计划

2021-08-24 淮安装修公司

其中db_p,p,p不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称。 ?php

include_once (\'inc/db_p\');

include_once (\'inc/p\');

include_once (\'class/p\');

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.\"f\";

LED照明行业的市场推广 }

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=\'p?id=xxx\' width=\'50\' height=\'50\'

p及上面的那个php文件,id=xxx是数据库里的记录ID,width是缩略图的宽,height是缩略图的高,请不要同时宽高都上,例如,你要实现宽为50的缩略图,只要img src=\'p?id=xxx\' width=\'50\'这样就可以了。

查看本文来源

南宁好男科医院
沈阳前列腺炎治疗哪家好
海口宫颈糜烂治疗费用多少钱
为你推荐