文件下载在cakephp 1.3中

时间:2015-01-05 08:04:58

标签: download cakephp-1.3

我使用代码从webroot之外的目录下载图像,但它不起作用。 这是我的控制器代码:

public function download() {


$this->autoRender = false;
        $this->view = 'Media';
        $type = explode('.',$this->params['pass'][1]);
        // Download app/outside_webroot_dir/example.zip
        $params = array(
            'id'        => $this->params['pass'][1],
            'name'      => $this->params['pass'][0],
            'download'  => true,
            'extension' => $type[1],
            'path'      => APP . 'media' . DS .'DealMenu'. DS . $this->params['pass'][0]. DS . $this->params['pass'][1]
        );
        $this->set($params);
    }

0 个答案:

没有答案