Maison  >  Article  >  développement back-end  >  PHP用流方式制作缩略图_PHP教程

PHP用流方式制作缩略图_PHP教程

WBOY
WBOYoriginal
2016-07-15 13:23:22789parcourir

其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称。

<p><?php <br>include_once ('inc/db_mysql.inc.php');<br>include_once ('inc/config.php');<br>include_once ('class/function.php');</p><p>global $picPath;</p><p>if (strstr($_SERVER[HTTP_USER_AGENT],"MSIE")) {<br>$attachment = '';<br>} else {<br>$attachment = ' atachment;';<br>}</p><p>$image = getInfo('newssp_gallery','id',$_GET['id']);</p><p>$filename = $picPath.$image['filename'];</p><p>if (!file_exists($filename)) {<br>$filename = $picPath."notexist.gif";<br>}</p><p>header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1<br>header("Cache-Control: post-check=0, pre-check=0", false);<br>header("Pragma: no-cache");// HTTP/1.0</p><p>header("Content-disposition:".$attachment." filename=".$image['original']);</p><p>$size = @filesize($filename);</p><p>header("Content-Length: $size");</p><p>$fd = @fopen($filename,rb);<br>$contents = @fread($fd,$size);<br>@fclose ($fd);</p><p>echo $contents;<br>?></p>

使用的时候可以把在html文件里加上:PHP用流方式制作缩略图_PHP教程

showpic.php及上面的那个php文件,id=xxx是数据库里的记录ID,width是缩略图的宽,height是缩略图的高,请不要同时宽高都上,例如,你要实现宽为50的缩略图,只要PHP用流方式制作缩略图_PHP教程这样就可以了。

(责任编辑:

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446847.htmlTechArticle其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称。 include_once ('inc/db_mysql...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn