使用PHP进行文件下载,并重新命名
$timeout = 65;
$ch = curl_init();
if (!$ch) {
return false;
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
if ($data == false) {
curl_close($ch);
return false;
}
curl_close($ch);
$fp = fopen($fname, "w");
if ($fp != NULL) {
fwrite($fp, $data);
fclose($fp);
return true;
}
return false;
}