[ pecooou @ 01.07.2014. 09:21 ] @
Kada downloadujem PDF prikazuje da je dokument corrupted.

Evo koda iz PagesController:

Code:

    public function download($filename = null) {
        
        // Check if a filename was specified
        if (is_null($filename)) {
            $this->Session->setFlash('Sorry, no file was specified for download.');
            $this->redirect($this->referer());
        }
        
        $this->viewClass = 'Media';
        
        // Split the filename into it's constituent parts, i.e. the name and the extension
        $pathinfo = pathinfo($filename);
        
        $params = array(
            'id' => $filename,
            'name' => $pathinfo['filename'],
            'extension' => $pathinfo['extension'],
            'path' => 'downloads' . DS,
            'download' => true,
            'mimeType' => $this->__getMimeType($pathinfo['extension'])
        );
        
        $this->set($params);
        
    }
    
    /**
     * __getMimeType function.
     * 
     * @access private
     * @param mixed $extension
     * @return void
     */
    private function __getMimeType($extension) {
        
        switch ($extension) {
            case "pdf":
                return "application/pdf";
                break;    
        }
        
    }




Ako bi neko mogao da pomogne, puno bi mi znacilo.

P.S. Verzija Cakea je 2.3.

[ drjekyll87 @ 21.08.2014. 13:58 ] @
mozes da download-ujes pdf i pomocu ove f-je, da ne koristis Media

public function downloadPdf($fileName) {

$path = APP . 'Vendor' . DS . 'pdf' . DS . $fileName . '.pdf'; //full path to file
$this->response->file($path, array(
'download' => true,
'name' => $fileName,
));
return $this->response;
}