如何保存页面中的图片? 我的页面中有这么一个图片:<img id=a name=a src="http://b.com/c.php">用户打开这个页面时,会从b.com请求一个图片,我如何能够将这个图片保存下来?请高手指点。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是你自己的文件么、 可以在c.php后加上image格式($image,目标位置)进行生成图片看起来貌似是验证码一类的吧! <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/本地生成图片地址") 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].' />'; }} 关于点击刷新验证码的问题 什么情况下需要做数据库主从备份 一个基础问题 关于随机数 紧急。。。。望高手指点! 想做一个访问者的ip和地理位置的统计。 mysql排名问题 请教关于MySQL4的搜索问题 如何用javascript实现服务器端和客户端的时间差。。。 恶意解析的问题 如何将不同文件夹下的需求的图片复制到新文件夹去? 如何复位结果集状态
image格式($image,目标位置)进行生成图片
看起来貌似是验证码一类的吧!
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].' />';
}
}