PHP 远程图片获取到本地

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

    <?php   
    /* 
     * 远程图片获取到本地 
     */  
    function GrabImage($url){  
        if($url != ""){ //如果图片地址为空  
            $ext = strrchr($url,'.');   //判断图片的格式  
            if($ext != '.jpg' && $ext != '.gif' && $ext != '$png'){  
                return false;exit;  
            }  
            $filename_r = time().rand(10,9000).$ext;    //给图片命名  
            $filename = 'getimg/'.$filename_r;  
            ob_start(); //打开缓冲区  
            readfile($url);   
            $imginfo = ob_get_contents();   //获得缓冲区的内容  
            ob_end_clean(); //清除并关闭缓冲区  
            $fp = fopen($filename,'a');   
            fwrite($fp,$imginfo);  
            fclose($fp);  
        }else{  
            return false;  
        }  
    }  
    $start_time = microtime(true);  
    GrabImage("http://img4.shougongke.com/Public/advance/53846840dafb4.jpg");  
    $end_time = microtime(true);  
    $time = round($end_time-$start_time,3);  
    echo '程序总共用时'.$time.'秒';  
    ?>