我正在使用mssql服务器和配置文件将数据库文件自动备份到某个文件夹,现在我需要让用户从服务器上下载文件到本地机器。我该如何让用户从服务器上下载文件
$filename = basename($_GET['file']);
// Specify file path.
$path = 'backups/hello.txt';
$download_file = $path.$filename;
if(!empty($filename)){
// Check file is exists on given path.
if(file_exists($download_file))
{
header('Content-Disposition: attachment; filename=' . $filename);
readfile($download_file);
exit;
}
else
{
echo 'File does not exists on given path';
}
}
}
我试过这一个,但它说文件是未知的。
我觉得应该是'$ PATH = '备份/';'。 – Spectarion
@Spectarion 消息:未定义索引:文件 – cks
向我们显示您正在访问的链接。 – Spectarion