- Posts: 22
- Thank you received: 1
Open downloads in browser
6 years 5 months ago #318133
by DavidVogt
Open downloads in browser was created by DavidVogt
-- Joomla version -- : 3.9.18
-- PHP version -- : 7.2
Hi there, I'm using the "files" section of the product pages to upload PDF manuals for products. My client has asked me to somehow change the browser behavior to open the PDF files in the browser, rather than a file download. Any advice would be greatly appreciated!
-- PHP version -- : 7.2
Hi there, I'm using the "files" section of the product pages to upload PDF manuals for products. My client has asked me to somehow change the browser behavior to open the PDF files in the browser, rather than a file download. Any advice would be greatly appreciated!
Please Log in or Create an account to join the conversation.
6 years 5 months ago #318157
by nicolas
Replied by nicolas on topic Open downloads in browser
Hi,
First, note that this can depend on the browser's settings:
apemobile.zendesk.com/hc/en-us/articles/...opening-in-a-new-tab
Second, in the headers sent back to the browser, HikaShop specifies a genertic content-type, and is also doesn't set the content-disposition to inline: stackoverflow.com/questions/34891513/vie...stead-of-downloading
That's because HikaShop can be used with many different types of files and this is not necessarily wanted.
So in the file administrator/components/com_hikashop/classes/file.php, you'll find this code:
Changing them to:
should help but note that it might be an issue if you have other files that aren't PDF files as downloadable files on your products.
First, note that this can depend on the browser's settings:
apemobile.zendesk.com/hc/en-us/articles/...opening-in-a-new-tab
Second, in the headers sent back to the browser, HikaShop specifies a genertic content-type, and is also doesn't set the content-disposition to inline: stackoverflow.com/questions/34891513/vie...stead-of-downloading
That's because HikaShop can be used with many different types of files and this is not necessarily wanted.
So in the file administrator/components/com_hikashop/classes/file.php, you'll find this code:
Code:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $name . '"');
Code:
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $name . '"');
Please Log in or Create an account to join the conversation.
Time to create page: 0.134 seconds