Reputation: 8168
I am using PDF.js
to open a PDF
file currently and its working fine.
Previously I was using like this:
http://myapp.mycompany.com/web/viewer.html?file=http://myapp.mycompany.com/my-PDF-file.pdf
My Problem:
For some reasons, I really do not want to reveal the file path of my PDF file and want to move my PDF files outside root directory. Is there any other way to provide the pdf file to the viewer.html? or is this the oly way?
NOTE: I have moved all the PDF files outside my root directory. So How can I access the PDF now?
Upvotes: 0
Views: 3775
Reputation: 2691
Use rawurlencode
to encode '/getPDF.php?filename=pdfname.pdf' part:
"http://myapp.mycompany.com/web/viewer.html?file=".rawurlencode("/getPDF.php?filename=".rawurlencode("pdfname.pdf"))
Upvotes: 0
Reputation: 43481
Yes, there is. Call some function instead (and you don't even need PDF.js):
http://www.example.com/getPDF.php?fileName=pdfname.pdf
function fileName() {
$fileName = $_GET['fileName'];
header("Content-type:application/pdf");
header("Content-Disposition:inline;filename='{$fileName}'");
readfile(__DIR__."/../pdfs/private/{$fileName}");
}
Upvotes: 4