这段代码允许你通过php内置方法下载其它网站上的文件,无需安装任何扩展
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; } } }