Page 1 of 2

Open PDF Files instead of downloading them

Posted: 06 Jun 2020, 18:15
by latorreinfo
I've just installed phocadownload so may have missed something.

I'd like to be able to open and view pdf files in the browser rather than have them downloaded.

I know browsers can be set up to do this but that relies on users knowing how to do this. Another extension I use opens the file rather than downloads it, so it must be possible

Re: Open PDF Files instead of downloading them

Posted: 06 Jun 2020, 18:27
by Benno
Hi,
see: viewtopic.php?f=31&t=60744

Kind regards,
Benno

Re: Open PDF Files instead of downloading them

Posted: 07 Jun 2020, 01:09
by latorreinfo
Benno , thank you for your help

Is there any way to only have the preview button and suppress the download option, other than using a customised layout

Kind Regards
Dave

Re: Open PDF Files instead of downloading them

Posted: 07 Jun 2020, 09:29
by Benno
Hi,
no, I do not know a way to hide the download button in the options.
So only CSS remains.

Kind regards,
Benno

Re: Open PDF Files instead of downloading them

Posted: 07 Jun 2020, 13:25
by christine
Hi,

as Benno wrote, via CSS, example from a demo, as live site not available:

Code: Select all

.pd-button-download {
display:none;	
}
or via Template Override from:

/components\com_phocadownload\views\category\tmpl\default_files.php

belongs apprx. to these lines:

Code: Select all

// pdbuttondownload
			$pdButtonDownload = '<div class="pd-button-download">';
			$pdButtonDownload .= str_replace('class=""', 'class="'.$cBtnSuccess.'"', $linkDownloadB) . JText::_('COM_PHOCADOWNLOAD_DOWNLOAD') .$linkDownloadE;
			
			$pdButtonDownload .= '</div>';
e.g. to comment out.

if using Bootstrap Output:
components\com_phocadownload\views\category\tmpl\default_files_bootstrap.php

to:
templates/your_template/html/com_phocadownload/category/directory

Kind regards
Christine

Re: Open PDF Files instead of downloading them

Posted: 07 Jun 2020, 15:18
by latorreinfo
Thanks, another question

- do you know the routine that invokes the actual download of the file. I'm wondering if its possible to change the behaviour so the browser decides whether to do a download or process the file (eg display a pdf file) rather than a download happenig every time.

-i'm wondering if this is could be used as an alternative to view - which doesnt appear to work on an _ _ or _ _ as only the first page gets displayed.

Re: Open PDF Files instead of downloading them

Posted: 07 Jun 2020, 19:30
by Jan
Hi, the main function of the component is download component. So it means, it tries to force downloading the file before displaying it when the download button is clicked.

Everything with download happens here:
administrator\components\com_phocadownload\libraries\phocadownload\download\download.php

including the setting of header which tries to force downloading instead of displaying, etc.

So if there should be done some changes, then in this file.

Jan

Re: Open PDF Files instead of downloading them

Posted: 08 Jun 2020, 11:46
by latorreinfo
Jan

thank you - I will take a look

Re: Open PDF Files instead of downloading them

Posted: 09 Jun 2020, 12:25
by latorreinfo
Jan.
thanks for you advice - by changing 'content-disposition: attachment' to 'content-disposition: inline' I can now view the file rather than downloading it when the download button is clicked. The advantage of this is 'viewing' is now controlled by security constraints so the file can be in a protected directory outside of public_html or controlled by .htaccess and stopping direct downloads using a URL in the browser.

Maybe the inline option could be considered as a configuration option for a future release.

As an aside the forum search appears to only display the first few results and I cannot see a way to scroll furhter down?
Dave

Re: Open PDF Files instead of downloading them

Posted: 11 Jun 2020, 02:01
by Jan
Hi, Ok, added to feature request list.

Forum - do you get any Javascript error? Which browser do you use?

Jan