作者:小鱼儿r6K2 | 来源:互联网 | 2017-05-14 02:21
求教:使用PHP的函数fpassthru()显示图片详解新学PHP,可能没问到点子上,大概意思是这样的:wamp环境,zend框架+smarty模板1.<imgsrc"controlleraction参数1参数值">然后在action里边用fpassthru传递一个图片来显示是否可行?怎么写?2.
求教:使用PHP的函数fpassthru()显示图片详解
新学PHP,可能没问到点子上,大概意思是这样的:
wamp环境,zend框架+smarty模板
1.
然后在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;
------解决方案--------------------
apache 下防盗链可以用rewrite_module,用这些输出文件头的方法来处理只会让服务器负担加重.
http://sealbird.iteye.com/blog/976891
------解决方案--------------------
------解决方案--------------------
注释掉 header("Content-Length: " . filesize($imgpath));
header("Content-Type: image/jpg");
后,只能是图片数据流