APP NEWS
php实现将远程文件下载保存到服务器指定文件夹
直接上代码啦.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2015-06-28 00:000 次阅读
直接上代码啦..
- set_time_limit (24 * 60 * 60);
- if (!isset($_POST['submit'])) die();
- $destination_folder = './downfolde/'; // 文件夹保存下载文件。必须以斜杠结尾
- $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);
- }
- ?>
关键词标签:服务器 指定 文件夹 保






