Unable to view PDFs direct in browser
Posted: 24 May 2024, 04:01
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
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