代码很简单就不多废话了,直接奉上:
array(
"method"=>"GET",
"header"=>"",
"timeout"=>$timeout)
);
$context = stream_context_create($opts);
if(@copy($url, $file, $context)) {
//$http_response_header
return $file;
} else {
return false;
}
}
}
?>再来个远程下载文件到服务器
< ?php // maximum execution time in seconds set_time_limit (24 * 60 * 60); if (!isset($_POST['submit'])) die(); // folder to save downloaded files to. must end with slash $destination_folder = 'temp/'; $url = $_POST['url']; $newfname = $destination_folder . basename($url); $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); } ?>以上所述就是本文的全部内容了,希望大家能够喜欢。
1.) 将所有文件解压到php环境中,本程序才用smarty+php+mysql设计。如果运行不了,请修改hhy文件夹下的smarty.php文件改法请看说明2.) 修改configs下的config.inc.php下的连接数据库的密码和用户名3.) 本程序没有做安全页面,人工导入sql.inc到mysql数据库。管理员初始化帐号为admin,密码为hhy。后台地址:http://你的网站地址/h
更多PHP实现远程下载文件到本地相关文章请关注PHP中文网!










