Thanks for any help offered
PHP Include
Moderator: General Moderators
PHP Include
Hello everyone, I just found this website. I work with macromedia software and I tried this question on their forum, and no one knew the answer. I built and manage a site http://www.centurionams.com The site is built using php, css, and flash. The template is the same on every page, and I use <?php include()?> to repeat objects such as the navigation menu, images, and body content. most of the included files either end in .php, or .inc. Now to my question. The login area for clients contains pdf files located within other folders and directories. I tried using the php include tag and I get a parse error. Can pdf files be included with php?, and if so can someone tell me how to do this? If it can not be done let me know.
Thanks for any help offered

Thanks for any help offered
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the include and require functions will cause php to attempt parsing of the file specified. Depending on what you are doing with them, try using readfile() in combination with several header() calls stating that the page is an inline pdf file.
PDFs have a different encoding to a simple HTML-page. You will need to indicate to the browser what you're passing to it, otherwise it's Goobledigook and the browser displays it as such. With HTML it's done with <DOCTYPE ...> (and most browser default to HTML anyway.)
No browser I know of has an inbuilt PDF-reader, thus the browser relies on an external application. You need to specify that with MIME (see this tutorial) and pass it to the browser. For an example see viewtopic.php?t=19670 - note that you'll have to pass the appropriate MIME format in
(in this example an octet-stream). Replace that with the pdf-MIME format.
You can't have both HTML and PDF in one page unless you make use of frames - which I haven't tried, but it should theoretically be possible (but a "dirty" solution).
No browser I know of has an inbuilt PDF-reader, thus the browser relies on an external application. You need to specify that with MIME (see this tutorial) and pass it to the browser. For an example see viewtopic.php?t=19670 - note that you'll have to pass the appropriate MIME format in
Code: Select all
header("Content-type: application/octet-stream");You can't have both HTML and PDF in one page unless you make use of frames - which I haven't tried, but it should theoretically be possible (but a "dirty" solution).
PHP/Pdf Include
Thanks again
Rachael