2014-11-21 103 views
0

我有一个文件,让我们说sample.xml中位于www.sample.com如何从URL下载文件到脚本的ftp?

我想一个脚本,比如说的download.php位于www.download.com

的download.php下载样本.XML并将其存储在download.com的FTP

我有这样的代码,但它下载到用户本地计算机

$file_url = 'http://sample.com'; 

    header('Content-Type: application/octet-stream'); 
    header("Content-Transfer-Encoding: Binary"); 
    header("Content-disposition: attachment; filename='sample.xml'"); 

readfile($file_url); 

有人可以建议的方式来直接下载到FTP主机?

+1

使用'的file_get_contents()'从URL获取文件和'file_put_contents()'把文件服务器上 – 2014-11-21 09:36:54

回答

0
$sample = file_get_contents('http://www.sample.com/sample.xml'); 
file_put_contents('sample.xml', $sample); 

做这样的