首页 > 解决方案 > 下载 zip 文件夹后,旁边的代码不起作用

问题描述

我正在使用 PHP 代码点火器,我在下面编写了代码来下载文件。它读取文件并将其下载为 zip。它工作正常。但是当我在下面下载其他代码时,它会停止工作。例如,如果我回显两位数的总和,它将不起作用。有人会指导我吗?

$this->zip->read_file($path);
$filename= "zip-name";
$done = $this->zip->download($filename);

//下面的代码不起作用

$a=10;
$b=10;
echo $a+$b;

标签: codeigniter

解决方案


这是预期的行为。请参阅 Codeigniter Docs 中有关该功能的提示:

Do not display any data in the controller in which you call this method since it sends various server headers that cause the download to happen and the file to be treated as binary.

这就是为什么下载平台通常会执行延迟的、JavaScript 控制的重定向(“您的下载将很快开始......”)


推荐阅读