【发布时间】:2013-08-28 17:07:02
【问题描述】:
我刚刚从 cakephp 1.1 升级到 1.3。除了创建和下载 zip 文件之外,我已经更新了网站上的所有内容,并且运行良好。
这是我的 accounts_controller.php 中的代码:
function zip() {
$this->checkSession();
$this->checkUpgradedAccount();
$files = array();
$this->layout="zip";
/*
code where I locate the files to zip, combine them, etc
*/
$tmp_file = "/home/[userdirectory]/tmp/".md5(mktime()).".zip"; //directory name edited
$command = "/usr/bin/zip -j $tmp_file ".implode(" ",$zip_files);
exec($command);
foreach($zip_files as $zf) {
unlink($zf);
}
$file_path = $tmp_file;
$this->set("path",$file_path);
$this->render();
}
但是,当我调用此操作时,出现错误:
错误:在此找不到请求的地址“/accounts/zip” 服务器。
它在 1.1 版中的工作方式与此类似。我假设发生了一些变化,但我不确定是什么,并且无法在文档中找到任何相关内容。
zip.ctp 视图文件确实存在,但其中除了:<?php ?>
我怀疑布局有些不同。 /layouts 目录中没有“zip.ctp”。但是,我已将该行更改为$this->layout('default');,它呈现一个没有错误的空白页面,但也没有下载。
请指导我在 cake 1.3 中下载我的 zip 文件的正确方法。提前致谢。
【问题讨论】:
标签: cakephp download zip cakephp-1.3 render