求教:使用PHP的函数fpassthru()显示图片详解
新学PHP,可能没问到点子上,大概意思是这样的:
wamp环境,zend框架+smarty模板
1.%20然后在action里边用fpassthru传递一个图片来显示%20%20%20是否可行?%20怎么写?
2.%20不用img标签%20用fpassthru%20可以传递图片到前台么?
——解决方案——————–
…Action{
//1可以直接输出图片内容例如用你说的fpassthru:
- PHP%20code
//%20以二进制格式打开文件$name%20=%20'./img/ok.p4本文¥来源gao!%daima.com搞$代*!码$网9
搞代gaodaima码ng'$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");
后,只能是图片数据流