Page 1 of 1
PHP Include
Posted: Tue May 11, 2004 3:53 pm
by rache2000
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

Posted: Tue May 11, 2004 4:20 pm
by magicrobotmonkey
you can link to them, but i dont think they can be included into an html page
Posted: Tue May 11, 2004 4:35 pm
by feyd
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.
Posted: Tue May 11, 2004 4:39 pm
by patrikG
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
Code: Select all
header("Content-type: application/octet-stream");
(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).
PHP/Pdf Include
Posted: Wed May 12, 2004 10:41 am
by rache2000

Thanks for the information from everyone. I understand how it works now. I set up a quick demo using the headers and readfile function, and it worked.
Thanks again
Rachael
Posted: Wed May 12, 2004 10:44 am
by patrikG