直接上代码:
function download_file($url = '', $fileName = '')
{
$ch = curl_init();
$fp = fopen($fileName, 'wb');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
测了一下, 靠谱。