Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
pass secure file to pdf.js/viewer.html with php

I am experimenting with the pdf.js examples, and in particular the viewer.html/viewer.js. I am trying to access a URL outside of the webroot. My PHP installation has access to a specific folder outside webroot where I store pdf files. In PHP I stream these files to the browser for download, which works fine. However, I would like to also stream the file to the viewer directly. Is that possible?

So, for example, my URL would be /web/viewer.html?file=12345.pdf for a file that is accessible to the web browser. However, if I want to stream this from outside the root, the URL may look like this: /web/viewer.html?file=fetch.php?id=12345

Any idea how I should go about this, as the viewer seems to fetch the filename directly.

One idea I explored is to create a temporary copy within webroot. Pass that file to the viewer and delete the file after a set period to ensure it was loaded. That seems awfully inefficient, so somehow passing the file directly to the viewer so it can be used without creating a temp copy seems to be a better approach, if possible. Any ideas are much appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!