通过URL保存文件

 1 <?php 
 2 
 3 function dlfile($file_url, $save_to)
 4 {
 5     $content = file_get_contents($file_url);
 6     file_put_contents($save_to, $content);
 7 }
 8 
 9 $furl = 'http://www.acadsoc.com.cn/Curriculum/20160602/f837101a-f5a5-4fa3-8560-fb2c4d9e7570.pdf'; // 传入URL地址
10 
11 $sto = 'text.pdf'; // 要保存的文件名,文件后缀可以通过截取url的文件后缀获取
12 
13 dlfile($furl,$sto);
14 ?>
原文地址:https://www.cnblogs.com/chenrunxuan/p/7698265.html