function cdfile($rurl,$lcfile){$ch=curl_init($rurl);$downloadPath=$lcfile;$downloadPathName=$downloadPath;$lcpath=urltopath($lcfile);is_dir($lcpath) OR mkdir($lcpath, 0777, true); $fp=fopen($downloadPathName,'wb') or die('open failed!');curl_setopt($ch,CURLOPT_FILE,$fp);curl_setopt($ch,CURLOPT_HEADER,0);$res=curl_exec($ch);curl_close($ch);fclose($fp); }//新建或打开文件,将curl下载的文件写入文件
说明:rurl是远程地址,lcfile是本地保存地址,拿去自己试验,遇到不好用的代码,请告诉我,谢谢。