山仔's blog山仔's blog

利用php远程下载功能解决FTP上传慢的问题

在网上找到的方法,非常适合咱们这些用国外空间的朋友,特别是转移博客的时候就非常有用了。废话不说,直接看代码吧:

<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php
$pwd='comsing';//这里为你的密码
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 = './';
$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!';
}
?>

使用方法:
将这个代码保存为down.php 上传到你的服务器,然后访问这个地址down.php?pwd=’你的密码’
然后在输入框输入你要下载的文件的地址就OK了
是不是速度非常快了?

本文遵循 BY-NC-SA 3.0 协议. 转载请注明转自 | 当前页面:山仔's blog » 利用php远程下载功能解决FTP上传慢的问题

评论