新建一个images.php文件
代码如下
<?php
//header('Content-Type:image/gif');
readfile(base64_decode(trim($_GET['imgid'])));
?> 调用代码是:
<img width=310 src="images.php?imgid=<?php echo base64_encode($pic_url) ?>" height=310>
$pic_url为远程动态的图片地址比如我想调用http://images.chinaz.com/tool/bainian.gif图片地址
通过加密侯得到的地址是:images.php?imgid=aHR0cDovL2ltYWdlcy5jaGluYXouY29tL3Rvb2wvYmFpbmlhbi5naWY=
这样可以正常显示,但是刷新一次后用调用不出来了
提示Warning: readfile(http://images.chinaz.com/tool/bainian.gif) [function.readfile]: failed to open stream: HTTP request failed! in d:\xxxxx\xxxxx\wwwroot\images.php on line 3
时隔几秒后又正常了请问怎么解决呢?请问还有其他的图片地址加密方法吗?php的

解决方案 »

  1.   

    1 header('Content-Type:image/gif');
    还是要加的
    2 另外你的这个只是base64编码,不是加密。
      

  2.   


    这是我ad.php中的内容,没问题:<?php
    header('Content-Type:image/jpeg');
    if(isset($_GET['imgid']))readfile(base64_decode(trim($_GET['imgid'])));
    ?>  <img width=310 src="ad.php?imgid=<?php echo base64_encode('aaa.jpg') ?>" height=310>
      

  3.   

    这样也能显示,但是再次刷新就出错了,要等几秒再刷新才显示,我调用的是远程的图片,会不会和时间有关系亚
    出错代码
    Warning: readfile(http://img03.taobaocdn.com/bao/uploaded/i3/T1V3VyXfBsXXXKwXU._080900.jpg) [function.readfile]: failed to open stream: HTTP request failed! in d:\xxxx\xxx\wwwroot\ad.php on line 5
      

  4.   

    http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2010/0826/5308.html
      

  5.   


    不显示,显示X
    通过图片地址访问出现下面的错误:
    Warning: readfile(http://img03.taobaocdn.com/bao/uploaded/i3/T1V3VyXfBsXXXKwXU._080900.jpg) [function.readfile]: failed to open stream: HTTP request failed! in d:\xxxx\xxx\wwwroot\ad.php on line 5