【发布时间】:2014-11-21 09:34:02
【问题描述】:
我有一个文件,比如说位于 www.sample.com 的 sample.xml
我想要一个脚本,例如位于 www.download.com 的 download.php
download.php 下载 sample.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 的方法吗?
【问题讨论】:
-
使用
file_get_contents()从url获取文件,使用file_put_contents()将文件放到你的服务器上