- <?php
- function get_file($url,$folder,$pic_name){
- set_time_limit(24*60*60); //限制最大的执行时间
- $destination_folder=$folder?$folder.'/':''; //文件下载保存目录
- $newfname=$destination_folder.$pic_name;//文件PATH
- $file=fopen($url,'rb');
- if($file){
- $newf=fopen($newfname,'wb');
- if($newf){
- while(!feof($file)){
- fwrite($newf,fread($file,1024*8),1024*8);
- }
- }
- if($file){
- fclose($file);
- }
- if($newf){
- fclose($newf);
- }
- }
- }
- get_file("<a href="http://www.baidu.com/img/baidu_logo.gif">http://www.baidu.com/img/baidu_logo.gif","file","baidu.jpg");
- ?>
- //该片段来自于http://www.codesnippet.cn/detail/210120131777.html
来源: http://www.codesnippet.cn/detail/210120131777.html