-
-
//php ob函数库抓取远程图片
- function GetImage($url, $filename = "") {
- if ($url == "") {
- return false;
- }
- if ($filename == "") {
- $ext = strrchr ( $url, "." );
- if ($ext != ".gif" && $ext != ".jpg") {
- return false;
- }
- $filename = time () . $ext;
- }
//文件 保存路径
- ob_start ();
- readfile ( $url );
- $img = ob_get_contents ();
- ob_end_clean ();
- $size = strlen ( $img );
//文件大小
- $fp2 = @fopen ( $filename, "a" );
- fwrite ( $fp2, $img );
- fclose ( $fp2 );
- return $filename;
- }
GetImage ( "http://XXXXX" );
复制代码
|