codeigniter - 下载 zip 文件夹后,旁边的代码不起作用
问题描述
我正在使用 PHP 代码点火器,我在下面编写了代码来下载文件。它读取文件并将其下载为 zip。它工作正常。但是当我在下面下载其他代码时,它会停止工作。例如,如果我回显两位数的总和,它将不起作用。有人会指导我吗?
$this->zip->read_file($path);
$filename= "zip-name";
$done = $this->zip->download($filename);
//下面的代码不起作用
$a=10;
$b=10;
echo $a+$b;
解决方案
这是预期的行为。请参阅 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 控制的重定向(“您的下载将很快开始......”)
推荐阅读
- macos - 如何强制 Homebrew 使用新安装的 curl 版本?
- c++ - CMake Visual Studio Group 共同构建了来自柯南的 dll 和依赖 dll
- azure - 通过 Visual Studio 发布的 Azure 函数
- koin - 在 Kotlin Native 中提供依赖项时,Koin 的行为是什么?
- cypress - 赛普拉斯断言错误:找到文本但它说它没有找到它
- r - 在 material_modal 中渲染 R/Shiny glide 组件
- python - 在不使用python循环的情况下在目录中查找第一个文件
- python - 问题创建 Django 模型
- variables - 是否可以从共享库/dll 外部修改静态变量?
- generics - VHDL:在通用映射中使用类型“时间”