【发布时间】:2015-02-14 18:58:41
【问题描述】:
我有一个带有 URL 的文件!
$url = "http://www.example.com/aa.txt";
我想下载此文件并将其保存到我网站上的路径
这是我的网站(在线)
$path = "server/username/";
我希望将 $url 文件保存到 $path ,,
我试试这个
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
?>
当我测试代码时,它使文件下载到我的电脑而不是我的网站
【问题讨论】:
标签: php