2014-11-21 111 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); 

做這樣的