php - XAMPP iframe not working inside localhost


I am trying to use an iframe to embed a pdf into a webpage. for some reason the pdf wont display (appears blank) and i'm prompted to download the file. This happens when i run the code from localhost server. however if i run the code outside localhost the iframe displays the pdf doc as it should. i have also tried using<embed> ,<object> and pdf.js they all gave the same outcome.


echo'<div class="main_content_view">
<iframe  src="pdf/pdf1.pdf" id="pdf_content"
width="700px" height="800px">

i've also tried adding$cfg['AllowThirdPartyFraming'] = true; to the and it still didnt work. Any ideas on how i could get the pdf to display in localhost as it does when i right click and open the php directly with a browser?




The thing is probably that a simple iFrame does not support viewing a PDF file. And afaik PDF.js is only for Firefox browser but I am not entirely sure about that. What you can try is PDFObject. This lets you dynamically embed your PDF in HTML documents using JS.

People are also looking for solutions to the problem: arrays - Query with two conditions PHP


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.