SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Why wont this PDF header() work?
-
Feb 27, 2008, 03:47 #1
- Join Date
- Aug 2004
- Location
- San Clemente, CA
- Posts
- 859
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Why wont this PDF header() work?
Why wont the header() parse the pdf? It shows up as encripted with weird characters. If $type = 1, it is a pdf and i have to parse it with a PDF header, else if it is $type = 2 do something else.
My issue is with this header, does it have to appear on the first line on the page? how can i have a script switch out header() types for different types of content?
Code PHP:<html> <head> </head> <body> <?php $type = $_GET['type']; if ( $_SESSION['valid_user'] ) { if ($type == "1"){ $fileName = "pdf/filename.pdf"; header("Content-type: application/pdf"); readfile($fileName); } else if ($type == "2"){ // DO THIS } else { echo "You do not have permision to view this page"; } ?> </body> </html>
-
Feb 27, 2008, 03:55 #2
- Join Date
- Jun 2005
- Location
- Alkmaar, The Netherlands
- Posts
- 693
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have HTML before your header() call, if you were to turn this into application/pdf it wouldn't work
Turnware MVC - A new barebone, fast and flexible PHP5 framework!
Ruben Knol
Turnware MVC Lead Developer
-
Feb 27, 2008, 09:47 #3
- Join Date
- Nov 2004
- Location
- Lincoln Nebraska
- Posts
- 1,161
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Get rid of the HTML, because right now your document is having an identity crisis. After you do that, read the section in the manual on header, including the attached comments. Also take a look at the FAQ at fpdf.org and the fpdf source for information about difficulties with PDF and IE. Suffice it to say, that you will need far more than just a content-type header to make it work cross browser.
-
Feb 27, 2008, 12:55 #4
- Join Date
- Aug 2004
- Location
- San Clemente, CA
- Posts
- 859
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thats it, thanks
Bookmarks