首先,这可能是您服务器上的安全风险。
其次,这里的小未经测试的代码:
<?php
echo 'get file...';
$data=file_get_contents('http://...target-url...');
if($data===false)die('Failed getting file.');
echo 'saving file...';
$succ=file_put_contents('...target-file...',$data);
echo $succ ? 'Success' : 'Failed saving file';
?>
可用脚本(放入文件 “down.php” 在Web根):
<?php
echo 'get file...';
if(!isset($_REQUEST['from'])die('Fail: Parameter "from" not set.');
if(!isset($_REQUEST['to'])die('Fail: Parameter "to" not set.');
$data=file_get_contents($_REQUEST['from']);
if($data===false)die('Failed getting file.');
echo 'saving file...';
$succ=file_put_contents($_REQUEST['to'],$data);
echo $succ ? 'Success' : 'Failed saving file';
?>
使用(在运行来自网络浏览器):
http://yoursite.com/down.php?from=http://yourothersite.com/file-content.txt&to=/var/www/public_html/target.txt
警告:请确保您在使用后删除脚本,它是一个严重安全问题。
http://en.wikipedia.org/wiki/Wget我用它下载WordPress的直服务器 – Luke 2010-08-10 07:19:31