其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称。
| @@######@@ |
使用的时候可以把在html文件里加上:
showpic.php及上面的那个php文件,id=xxx是数据库里的记录ID,width是缩略图的宽,height是缩略图的高,请不要同时宽高都上,例如,你要实现宽为50的缩略图,只要这样就可以了。
<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><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p><p>$image = getInfo('newssp_gallery','id',$_GET['id']);</p><p>$filename = $picPath.$image['filename'];</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/2295">
<img src="https://img.php.cn/upload/ai_manual/001/246/273/175712873744733.png" alt="清程爱画">
</a>
<div class="aritcle_card_info">
<a href="/ai/2295">清程爱画</a>
<p>AI图像与视频生成平台,拥有超丰富的工作流社区和多种图像生成模式。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="清程爱画">
<span>170</span>
</div>
</div>
<a href="/ai/2295" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="清程爱画">
</a>
</div>
<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>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号