经测试代码如下:
/**
* 下载其它网站上的文件
*
* @param
* @arrange (512.笔记) jb51.cc
**/
if (!function_exists('fetch_remote_file')) {
function fetch_remote_file($file) {
$path = parse_url($file);
$fs = @fsockopen($path['host'],80);
if ($fs) {
$header = 'GET ' . $file . ' HTTP/1.0' . lnbr;
$header .= 'Host: ' . $path['host'] . str_repeat(lnbr,2);
fwrite($fs,$header);
$buffer = '';
while ($tmp = fread($fs,1024)) { $buffer .= $tmp; }
$matches = Array();
preg_match('/Content-Length: ([0-9]+)/',$buffer,$matches);
return substr($buffer,-@$matches[1]);
} else { return false; }
}
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/