"Kevin Thorpe" <kevin@pricetrak.com> wrote in message
news:3fabc94a$0$27619$afc38c87@news.easynet.co.uk. ..[color=blue]
> Kubaton Lover wrote:[color=green]
> > "Andy Hassall" <andy@andyh.co.uk> wrote in message
> > news:i7hnqvk3ac9g8hv1oe8o6nfdkk6kseqt9p@4ax.com...
> >[color=darkred]
> >>On Fri, 7 Nov 2003 10:06:25 -0600, "Kubaton Lover"[/color][/color][/color]
<nospam@goawayspam.com>[color=blue][color=green][color=darkred]
> >>wrote:
> >>
> >>
> >>>I have a pdf file (syllabus.pdf) on the server. I have written the
> >>>following PHP code. It correctly finds the file, but it is sending the[/color]
> >
> > file
> >[color=darkred]
> >>>back as text I think because I'm seeing the binary in the browser[/color][/color][/color]
rather[color=blue][color=green][color=darkred]
> >>>than seeing the PDF loaded by Adober Reader. I've done with with Perl,[/color]
> >
> > but
> >[color=darkred]
> >>>I've never tried this with PHP. Can someone point out what I'm doing[/color]
> >
> > wrong
> >[color=darkred]
> >>>and how to fix it so that my PHP script can serve PDFs?
> >>>
> >>><?php
> >>>header("Cache-control: no-store\n");
> >>
> >> Don't end the header lines with \n; PHP handles that in the header()[/color]
> >
> > function.
> >[color=darkred]
> >>>header("Content-type: application/pdf\n\n");
> >>
> >> The \n above probably ended the headers so this one isn't being picked[/color]
> >
> > up.
> >[color=darkred]
> >>>readfile("$DOCUMENT_ROOT/syllabus.pdf");
> >>
> >> $DOCUMENT_ROOT isn't set by anything in this script.
> >>
> >>--
> >>Andy Hassall (andy@andyh.co.uk) icq(5747695) (
http://www.andyh.co.uk)
> >>Space: disk usage analysis tool (
http://www.andyhsoftware.co.uk/space)[/color]
> >
> >
> > Thanks. I made the following changes and still no luck. I have[/color][/color]
confirmed[color=blue][color=green]
> > that the script is indeed finding the file though.
> >
> > <?php
> > header("Cache-control: no-store");
> > header("Content-type: application/pdf");
> > header("Content-Disposition: inline, filename=syllabus.pdf");
> > $filename = '/public_html/syllabus.pdf';
> > readfile($filename);
> > ?>[/color]
>
> Are you by any chance using Internet Exploder?
>
> IE often ignores mime types in favour of file extensions. I suggest you
> link to this php script as follows:
> <a href="http://www.server.com/script.php/syllabus.pdf">xxx</a>
>
> The trailing 'syllabus.pdf' might just make IE behave.[/color]
You are correct, I am using IE. When I add /syllabus.pdf to the url, it
prompts me to Open or Save the file which is unusual since other PDF files
(accessed directly) do not do that. If I click "Open", it behaves as if it
is downloading the pdf, but then returns the following error:
"Internet Explorer cannot download syllabus.pdf from
www.yourdomain.com.
Internet Explorer was not able to open this Internet site. The requested
site is either unavailable or cannot be found. Please try again later."