PHP 7 Script to Open Local PDF File or Document inside Web Browser Full Project For Beginners

 

Welcome folks today in this blog post we will be opening a local pdf file or document inside web browser in php 7.All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

index.php

 

 

<?php

// Store the file name into variable
$file = 'filename.pdf';
$filename = 'filename.pdf';

// Header content type
header('Content-type: application/pdf');

header('Content-Disposition: inline; filename="' . $filename . '"');

header('Content-Transfer-Encoding: binary');

header('Accept-Ranges: bytes');

// Read the file
@readfile($file);

?>

Leave a Reply