Skip to content

用php远程下载文件到服务器

2009 十一月 3
by 荒野无灯

由于我的ubuntu 9.04已经over 了,昨天重新装了9.10,很多东东都要重新弄,今天去
http://dlc.sun.com/virtualbox/vboxdownload.html#linux下载sun virtualbox ,却出现Server not found错误:
server_not_found

由于我记得以前在http://www.blinux.cn/using-php-remote-network-file-downloaded-to-the-server/看到的通过远程网络下载文件,于是决定试一试这个方法,因为我用的是美国的LP 主机,因此完全符合条件。不试不知道,一试吓一跳!
40几M的sun virtualbox竟然在几秒钟之内(一点都不夸张,绝对不超过5秒!)就下载完成了,终于知道什么叫网速快了。

这是php文件代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php
$pwd='238a87f99a5e3f8e76864182eba140cf';
if ($_REQUEST['pwd']!=$pwd)
exit('Sorry ,you are not validate user!');
// 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);
echo 'OK,File has been downloaded!';
}
?>

通过php下载文件:
php_down_file

几秒钟后文件就下载完成了,我通过ftp把它再下载到自己的电脑上:
downfile_from_ftp

已经下好的软件:
ftped_file

安装sun virtualbox:
install_sun_virtualbox

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:,欢迎点击这里捐赠以支持荒野无灯转播到腾讯微博 转播到腾讯微博

作者:荒野无灯
出处:Hacklog【Hacklog】

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】

本文链接: http://ihacklog.com/?p=2916

17 Responses Post a comment
  1. 十月 28, 2010

    灯哥你好 我想问问你的那图片上的firefox的扩展叫什么名字啊?可以看到css、cookies、information等等之类的,好强大。。。我也想下载个玩玩

  2. sjg permalink
    三月 31, 2010

    fopen被禁用怎么办,还有其他方法实现吗?

  3. 十一月 5, 2009

    好久没来了~

  4. 十一月 4, 2009

    突然发觉博主的时区 和偶的不同来。

  5. 十一月 4, 2009

    你的代码高亮 是用的插件还是自己修改的代码?。偶正在寻思这个问题呢,想着自己做个这样的插件用用。

  6. 十一月 4, 2009

    这个好

  7. 十一月 3, 2009

    其实本没有沙发,抢的人多了,沙发就诞生了

    想换个友链 不知博主意下如何?

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <q cite=""> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS