我在基于视频的网站上工作,我必须提供下载视频的链接。
我使用了下面的代码,它运行正常。
if (file_exists($FileDownload)) {
$Basename = pathinfo($FileDownload, PATHINFO_BASENAME);
$mime = 'application/force-download';
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: ' . $mime);
header('Content-Disposition: attachment; filename="' . basename($Basename) . '"');
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile("$FileDownload"); // push it out
exit();
}
$this->render(false);
它强行下载文件,它写在我的Controller操作上,并使视图呈现为false。
问题是当我点击下载并开始下载文件时,我无法在下载完成之前导航到其他页面。
谢谢!
答案 0 :(得分:0)
CakePhp响应文件是我的问题的解决方案。
更新代码
lwpd[4]