PHP下载远程文件到服务器

//下载远程文件到服务器
function dlfile($file_url, $save_to)
{
//$path=ROOT_PATH."public/uploads/app/".date('Ymd',time());
//$filename = date('YmdHis') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT).'.png';
try{
$content = file_get_contents($file_url);
file_put_contents($save_to, $content);
$res=1;
}catch (\Exception $e){
$res=0;
}
return $res;
}

THE END