Forum
Secure Downloads (Members) to allow for PDF Preview
Right now I've moved a lot of PDFs into the secure bucket outside of the webroot. I'm trying to preview some of these files onto the server as a little region of the webpage. This following code worked fine when the files were inside the webroot, but now is not working properly.
<iframe src="download.php?file=/test.pdf" type="application/pdf" width="800" height="600">
Is there a way to modify the download.php so that it can also potentially preview files outside the webroot?
Yes, most likely. What is in
download.php
?It is currently following the template from the documentations.
Are the files in the bucket called
secure
and is that bucket defined in your bucket list?Yes, the files are in the secure bucket. The secure bucket works perfectly fine. I'm able to put files into it through the Perch UI and it works fine on the actual webpage. The issue comes when I try to embed a pdf from the secure bucket. It no longer embeds the pdf and just starts the download.
the bucket config file --
What do you mean by embed in this context?
Previously we had a PDF preview box on a section of the webpage (w. width 800, height 600). It worked when the files were in the perch/resources folder but is no longer working now that we are grabbing the file through the download.php page.
Ok, I understand - you were using the browser's capability to display a PDF instead of force-downloading the file. Got it.
Instead of this:
do this:
That code causes the PDF to be previewed in another window.
I'm trying to make it so the PDF will be previewed on a webpage along with other content. It's similar to how the html <object> tag works. It was working when I still had the PDF files on the resource bucket within the webroot but now lost its functionality when it needs to be referenced through the download.php.
What HTML would you output for a static PDF file?
This is essentially how the HTML should look like after perch provided the file path:
There will be a button on the top of the page and then a PDF preview of the file directly below it.
The site is currently referencing the preview files without the download.php (via perch/resources) so that it will work. I would like to secure those PDF files with the members app and retain the ability to preview those files.
Yes, that should work. If not, do you have an example we can see?