Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda