php uses curl to grab remote images, which can solve the problem of anti-leeching.
function ycimg($file,$newfile) { // 初始化一个 cURL 对象 $curl = curl_init(); // 设置你需要抓取的URL curl_setopt($curl, CURLOPT_URL, $file); // 设置header curl_setopt($curl, CURLOPT_HEADER, 0); // 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 运行cURL,请求网页 $data = curl_exec($curl); // 关闭URL请求 curl_close($curl); //写入获得的数据 $write = @fopen($newfile,"w"); fwrite($write,$data); fclose($write); return TRUE; }