Skip to main content

Open downloads in browser

More
6 years 5 months ago #318133 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!

Please Log in or Create an account to join the conversation.

More
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:
Code:
header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $name . '"');
Changing them to:
Code:
header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="' . $name . '"');
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.

Please Log in or Create an account to join the conversation.

Time to create page: 0.178 seconds
Powered by Kunena Forum