troubleshooting Question

php file_get_contents of pdf not working in IE

Avatar of libramak
libramak asked on
PHPWeb BrowsersJScript
9 Comments1 Solution5850 ViewsLast Modified:
I am using php to view pdf files through the web browser.  The pdf file is stored outside of the root directory to deter direct linking (web page of pdf links requires password).  The link to the pdf file is as so:

<a href="caritas.php?file=priests/Caritas0809priests.pdf"> August 2009</a>


I am using ajax/jquery to open all pdf files in a new window.  

$(document).ready(function(){

    $("a[href$='.pdf'], a[href$='.doc'], a[href$='.xls']").click(function () {
           var features = "height=600,width=700,scrollTo,resizable=1,scrollbars=1,location=0";
            newwindow=window.open(this.href, 'Popup', features);
            return false;
      });



});
 
The pdf files open up in a new window in Firefox/Opera/Safari.  In IE, I just get a blank page where the source code is the following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>


--I  am able to view the PDF files in IE when I don't use the Javascript, that is, when the pdf is opened in the same window.  Is there something in my script that is causing this behavior in the IE browser?

Code to php file:
$file = $_GET['file'];
    $fileDir = '../../caritas/';

    if (file_exists($fileDir . $file))
    {
      
        $contents = file_get_contents($fileDir . $file);

       
        echo $contents;   
        
    }
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros