<BR>function grabImage($url, $filename = '') { <BR>if($url == '') { <BR>return false; //如果 $url 为空则返回 false; <BR>} <BR>$ext_name = strrchr($url, '.'); //获取图片的扩展名 <BR>if($ext_name != '.gif' && $ext_name != '.jpg' && $ext_name != '.bmp' && $ext_name != '.png') {<p>4本文¥来源gao!%daima.com搞$代*!码$网9</p><pre>搞代gaodaima码
return false; //格式不在允许的范围
}
if($filename == ”) {
$filename = time().$ext_name; //以时间戳另起名
}
//开始捕获
ob_start();
readfile($url);
$img_data = ob_get_contents();
ob_end_clean();
$size = strlen($img_data);
$local_file = fopen($filename , ‘a’);
fwrite($local_file, $img_data);
fclose($local_file);
return $filename;
}