求教:使用PHP的函数fpassthru()显示图片详解,该怎么处理

WBOY
Release: 2016-06-13 10:17:00
Original
911 people have browsed it

求教:使用PHP的函数fpassthru()显示图片详解
新学PHP,可能没问到点子上,大概意思是这样的:

wamp环境,zend框架+smarty模板

1.求教:使用PHP的函数fpassthru()显示图片详解,该怎么处理 然后在action里边用fpassthru传递一个图片来显示 是否可行? 怎么写?

2. 不用img标签 用fpassthru 可以传递图片到前台么?

------解决方案--------------------
...Action{
//1可以直接输出图片内容例如用你说的fpassthru:

PHP code
// 以二进制格式打开文件$name = './img/ok.png'$fp = fopen($name, 'rb');// 发送合适的报头header("Content-Type: image/png");header("Content-Length: " . filesize($name));// 发送图片并终止脚本fpassthru($fp);exit;<br><font color="#e78608">------解决方案--------------------</font><br>apache 下防盗链可以用rewrite_module,用这些输出文件头的方法来处理只会让服务器负担加重.<br><br>http://sealbird.iteye.com/blog/976891<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

楼上发的昨天我也搜到过,不过试了下,没成功 不知道是哪里的问题

后边的'rb' 应该是参数吧 这个参数我查了手册没查到 所以想来提问一下看看有没有更有用的资料

------解决方案--------------------
注释掉 header("Content-Length: " . filesize($imgpath));

header("Content-Type: image/jpg");
后,只能是图片数据流
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!