简体   繁体   中英

cakephp view PDF but not download

I am displaying a PDF file from my webroot folder using the following code:

$this->viewClass = 'Media';   
$ext = pathinfo($file,PATHINFO_EXTENSION);
$params = array(
            'name'      => 'File',
            'download'  => false,
            'extension' => 'pdf',
            'path'      => 'webroot/'.$file
        );
$this->set($params);

the file opens up in the brower(Chrome) but the save option appears with it too. Is there a way i can display the PDF, but the user is not able to download this file?

Simply nope. Because once the file is viewed in the browser it is downloaded and saved temporarily somewhere in the user's machine. May be you can implement your own control to view the PDF but disable saving it, using flash or java script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM