我的页面中有这么一个图片:<img id=a name=a src="http://b.com/c.php">用户打开这个页面时,会从b.com请求一个图片,我如何能够将这个图片保存下来?请高手指点。谢谢!

解决方案 »

  1.   

    是你自己的文件么、   可以在c.php后加上
    image格式($image,目标位置)进行生成图片
    看起来貌似是验证码一类的吧!
      

  2.   

    <img id=a name=a src="http://yourhost/getimage.php?url=http://b.com/c.php"> http://yourhost/getimage.php 为你服务器上文件 获取传递进来的 url 地址 用 file_get_contents 抓取传入连接(当然也可以用socket ) 然后生成本地文件  header("location: http://yourhost/本地生成图片地址")
      

  3.   


    function urlclean(&$buffer)
    {
        $buffer = preg_replace('#href\s*=\s*(["\'])\?#is', 'href = \\1' . SITEBASE .'?', $buffer);
        $buffer = preg_replace_callback('#<img(.*?)src\s*=\s*(["\'])([^"\']*?)\\2(.*?)/?>#is' , 'imageLocalize' , $buffer);
        return $buffer;
    }function imageLocalize($matches)
    {
        $stle = $matches[1] . $matches[4];
        preg_match_all('#width\s*(?:[\:="\']*?)(\d+)#is', $stle , $match);    if(in_array(substr($matches['3'],0,6),array('http:/','ftp://','https:')) && stripos($matches['3'] , SITEBASE) === false && stripos($matches['3'] , '.bmp') === false)
        {
            return '<img '.$matches[1].' src='.$matches[2].''.SITEBASE.'getimage.php?url='.$matches[3].($match[1][0] ? '&size='.$match[1][0] : '') .$matches[2]. ' '.$matches[4].' />';
        }
        else
        {
            return '<img '.$matches[1].' src='.$matches[2].$matches[3].$matches[2].' '.$matches[4].' />';
        }
    }