Unable to view PDFs direct in browser

Phoca Download - download manager
pun_issuer
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 24 May 2024, 02:11

Unable to view PDFs direct in browser

Post by pun_issuer »

I'm using phocadownload and plugins to display pdfs directly in the browser. I insert a phocadownload link into articles using the plugin and users can click the link to view the pdf directly in the browser. Each file has the General Options 'Direct Link' property set to yes to make this work. This worked well but then I started having a problem where files could not be viewed using direct links in the browser. The pdf contents were displayed as text/ascii characters as per the image below.

As I needed to upgrade the site from version 3 I restored an akeeba backup to a local host using WAMP and proceeded to upgrade to Joomla 5.1.0 and PHP 8.1.28

My upgrade path was:
1. restore akeeba backup locally using WAMP
2. export the old v3 phocadowload database tables as sql scripts
3. Uninstall the phoca components and plugins and then upgrade joomla to 4 and then to 5.0.2
4. reinstall the latest versions of phocadownload component (5.0.2), download button plugin (4.0.4) and download plugin (4.0.6)
5. Test phocadownload and plugins by creating a one category and one file to determine how attributes are populated ready for step 6
6. Modify and run table scripts based on step 5 to insert the old records for categories and phocadownload tables to restore index of files.
7. Successfully test locally on WAMP before restoring to live site
8. Successfully test live site - all files accessible using direct links viewable in browser

After a few weeks the problem reoccured and the pdfs were again not able to be viewed in the browser. It was possible to download the file locally if I change some of the Options in the PhocaDownload Component so the pdf file itself is valid. Sometimes I do get a an 'invalid token' error at first, before a second attempt downloads the file. I have also tried lots of different Options in the PhocaDownload Component without success.

Any thoughts on how to fix this? Is it possible that some of the new database table attributes are not populated correctly? It's odd that it worked for a while before breaking. I did compare the URL on the local site compared to the one issued in the live site and they were identical apart from the local host prefix. it looks like this:
https://www.hamiltonwheelers.com/genera ... ay-results

Any help would be greatly appreciated! Let me know if more info can assist

Sorry I'm a new user and can't get img tags to work (<10 post?) so here they are as direct links as well"

https://i.imgur.com/E2TxT8D.jpeg

https://i.imgur.com/4dQ21DE.jpeg

https://i.imgur.com/4Blwud0.jpeg
pun_issuer
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 24 May 2024, 02:11

Re: Unable to view PDFs direct in browser

Post by pun_issuer »

Just as a followup, I uninstalled phoca download and plugins, and create some categories and uploaded a single pdf file and it worked on my local setup. This is the most simple setup I could create.

I did exactly the same on the live host and the pdf are not able to be viewed in the browser. I also tried uploaded an image file and that also displayed as ascii/garbled in the browser. So it appears to be something in the host environment that is causing this issue. Any ideas?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Unable to view PDFs direct in browser

Post by Jan »

Hi, yes, in case you are using the same browser, then it seems to be some problem on your hosting. So the best way is to ask you hosting. :idea:

Jan
If you find Phoca extensions useful, please support the project
pun_issuer
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 24 May 2024, 02:11

Re: Unable to view PDFs direct in browser

Post by pun_issuer »

Jan wrote: 28 May 2024, 01:06 Hi, yes, in case you are using the same browser, then it seems to be some problem on your hosting. So the best way is to ask you hosting. :idea:

Jan
Thanks for the reply Jan. I'll see what I can do. I did discovery one more clue. If I enable logging, then click to view one of the files, the 'page' link created in the log entry works and views the pdf in the browser using an adobe extension. The URL in the log differs from that one that the plug in generated - it has a suffix on the end of the URL &vnrosnrosee=yes
e.g. plugin URL (does not work) https://www.hamiltonwheelers.com/genera ... ay-results

Logging URL (works!) https://www.hamiltonwheelers.com/genera ... nrosee=yes

If the plugin generated this URL it would work perfectly. The logging is also recording files that I am not directly downloading i.e. I clicked to download the file above, but another file is also recorded in the log. Could a page be trying to load or display files and creating extra log entries?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Unable to view PDFs direct in browser

Post by Jan »

Hi, the header of the file looks similar for both, so this is really a question on webhosting or for Joomla administration in case there is some specific feature like system plugin.

The communication happens between server and the user browser, so really hard to say what feature can influence it, I can imagine:

- some server option which changes it
- or some feature in Joomla (e.g. some specific system plugin) which somehow can influence it too. :idea:

Jan
If you find Phoca extensions useful, please support the project
pun_issuer
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 24 May 2024, 02:11

Re: Unable to view PDFs direct in browser

Post by pun_issuer »

Jan wrote: 28 May 2024, 15:16 Hi, the header of the file looks similar for both, so this is really a question on webhosting or for Joomla administration in case there is some specific feature like system plugin.

The communication happens between server and the user browser, so really hard to say what feature can influence it, I can imagine:

- some server option which changes it
- or some feature in Joomla (e.g. some specific system plugin) which somehow can influence it too. :idea:

Jan
Ok thanks for the reply Jan. No luck with the hosting company as yet but will advise if I find a solution, otherwise I will have to somehow migrate to an alternate file management system.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Unable to view PDFs direct in browser

Post by Jan »

Not sure if you exactly understand the problem, but this problem is not related to any file management system, this is the problem between browser and hosting (I unfortunately cannot say if this is on browser side or hosting side). The file managment system, just only mediate the communication between browser and hosting, so the hosting sends then the output to the user's browser - so in this case depends on browser or webserver what the output will be - in this end of communication, the mediator is not more included in this process.

Jan
If you find Phoca extensions useful, please support the project
Post Reply