nloding Posted May 29, 2008 Share Posted May 29, 2008 Here's what I want to do -- and I know it's possible, I just don't know how! I want to click a link that points to http://mysite.com/pages/somthing.php?id=x. Then I want to pull a filename from a database based on the key $_GET['id']. I want that file (which is going to be a PDF) to then be displayed on the page. HOWEVER! I do not want to a Header redirect so that URL is the file itself -- I want the URL to remain http://.../something.php?id=x. I've tried a ton of things I've found online, and none of them have worked. The basics I've found are this: <? header("Pragma: public"); header("Expires: Thu, 29 May 2008 05:00:00 GMT"); header("Cache-Control: must-revalidate"); header("Content-type: application/pdf"); header("Content-Length: ".filesize($file)); header("Content-disposition: inline; filename=$file"); header("Accept-Ranges: ".filesize($file)); readfile($file); exit(); ?> However, when I try that, it just sits there waiting on my webserver -- and my webserver isn't slow. I have a function that does a similar thing with Content-disposition: attachment to force a Save As dialog and that works fine. I've also tried using file read functions, and using a buffer ... notta! I've been looking at PDFLib and FPDF but neither seem to have ways to open an EXISTING PDF, just create NEW PDF's. Any help? Quote Link to comment https://forums.phpfreaks.com/topic/107727-solved-display-pdf-file-inline-how/ Share on other sites More sharing options...
nloding Posted May 29, 2008 Author Share Posted May 29, 2008 Nevermind, I'm an idiot. The relative path to the PDF was correct -- but it was being filtered through my master.php file and therefore dying. It's fixed and works. Quote Link to comment https://forums.phpfreaks.com/topic/107727-solved-display-pdf-file-inline-how/#findComment-552272 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.