Skip to content

Instantly share code, notes, and snippets.

@caovillanueva
Created October 17, 2022 17:46
Show Gist options
  • Save caovillanueva/963d18eab6c5cc20cfd45717c71c4930 to your computer and use it in GitHub Desktop.
Save caovillanueva/963d18eab6c5cc20cfd45717c71c4930 to your computer and use it in GitHub Desktop.
[PDF download insteaad of opening] Trick to force download file #PS17
If this problem is stil in the to do's list for anyone the solution for the latest Prestashop version (1.7.6.8) for opening PDF's or other documents in browser windows is to change 2 things:
1. Change the controllers/front/AttachmentController.php file like so:
ORIGINAL:
header('Content-Disposition: attachment; filename="' . utf8_decode($a->file_name) . '"');
CHANGED:
header('Content-Disposition: inline; filename="' . utf8_decode($a->file_name) . '"');
2. Change the .htaccess content of this line:
<FilesMatch "\.pdf$">
Header set Content-Disposition "Attachment" /// Alter this line like so: Header set Content-Disposition "Inline"
Header set X-Content-Type-Options "nosniff"
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment