Question

I just upgraded from cakephp 1.1 to 1.3. I have everything on the site updated and working great, except for creating and downloading zip files.

Here is the code in my 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();
}

When I call this action, however, I get an error:

Error: The requested address '/accounts/zip' was not found on this server.

It worked just like this in version 1.1. I'm assuming something has changed, but I'm not sure what, and was unable to find anything pertinent in the documentation.

The zip.ctp view file does exists, but it has nothing in it other than: <?php ?>

I suspect something is different with layouts. There is NO "zip.ctp" in the /layouts directory. However, I have changed that line to $this->layout('default'); and it renders a blank page with NO ERROR, but also with no download.

Please direct me on the proper way to download my zip file in cake 1.3. Thanks in advance.

Was it helpful?

Solution

You have two different problems here. That error you're getting is because you don't have a zip layout file. As for your problem with getting the zip file, you should be using the media view class - http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Views.html#media-views

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top