0

<?php
 $dirname = "pdf/";// Directory path
 $file = glob($dirname."*pdf");
  
foreach($file as $string){
 //header("Pragma: public", true);
 header("Expires: 0"); // set expiration time
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header("Content-Type: application/force-download");
 header("Content-Type: application/octet-stream");
 header("Content-Type: application/download");
 header("Content-Disposition: inline; filename=".basename($string));
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".filesize($string));
 die(file_get_contents($string));
        }
?>

I have multiple PDF's located in my system directory and I want them to display one after the other. In the above code, output is for one PDF file. I used foreach loop to iterate as I have multiple PDF's in my directory but I am able to retrieve only one PDF file. Second issue I am facing is, I am not able to view the PDF in full screen mode.I don't want the PDF to get downloaded instead it should display in full screen mode.

  • See these questions: http://stackoverflow.com/q/39735299/4205470 http://stackoverflow.com/q/3241326/4205470 http://stackoverflow.com/q/4371328/4205470 I am not familiar with PHP so I can't help solving your problem but I am pretty sure that setting headers with the same names _might_ cause problems. – Balázs Apr 11 '17 at 06:53
  • However, it might be that PHP concatenates the values, so never mind me if I am wrong about its behavior. – Balázs Apr 11 '17 at 06:56

0 Answers0