Categories: Php

Display PDF in browser via PHP

Share

Sometimes it is required to hide the actual PDF file name for security reason. So using a webpage you can display PDF in browser without knowing the actual URL.

Example source:

<?php
$file = 'path-to-pdf-file/myFile.pdf';
$filename = 'download.pdf';
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file);
?>

Save this file as pdf.php and run in a browser. You can see the PDF displaying on the browser.

Recent Posts

Unlock Growth – Guide to Online Financing and Business Loans for Entrepreneurs

If you are in a financial crisis , or need to start a new business…

22 hours ago

Optimize Your Hormonal Balance: Enclomiphene Citrate for Enhanced Wellness

Hormonal balance plays a pivotal role in overall well-being, influencing various aspects of health, from…

2 days ago

Paul Kanes Explores the World of Canine Companionship through Dog Walking

Dog walking is an excellent way to maintain your furry friend's camaraderie and provides many…

2 days ago

Top 5 Must-Have Features Every Mobile App Needs to Succeed

Introduction Businesses understand the diverse requirements of mobile applications, which provide a competitive advantage. There…

2 days ago

IoT Data Analytics: Ways to Gain Value from IoT Data

The Internet of Things (IoT) has recently changed the world. It links gadgets together and…

2 days ago

The Rise of NFTs: Exploring the Impact of Non-Fungible Tokens on the Digital Economy

NFTs, or Non-Fungible Tokens, are revolutionizing the digital economy. These unique digital assets, authenticated through…

3 days ago