Open downloads in browser

  • Posts: 22
  • Thank you received: 1
4 years 10 months ago #318133

-- 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.

  • Posts: 83410
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #318157

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:

				header('Content-Type: application/octet-stream');
				header('Content-Disposition: attachment; filename="' . $name . '"');
Changing them to:
				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.056 seconds
Powered by Kunena Forum
loading