[H-GEN] Pdf-php puzzle

Damien Ayers damien at omad.net
Mon Sep 27 12:17:58 EDT 2004


On Mon, 2004-09-27 at 21:16 +1000, Paul Clarke wrote:
> My site http://www.qfom.com.au/membership/ has the DocumentRoot line of
> the Apache conf file pointing to a php file, this works very well (as
> you would expect), however, I am using the following lines of php code
> to output the file if it is a pdf file:
> 
>       header("Content-type: application/pdf");
>       header("Content-Disposition: attachment; filename=".$file);
>       readfile($path.$file);

My first guess is that not sending a Content-Length header is confusing
either IE or your PDF viewer. Google turned up a note in the php manual
from someone who seems to have had the same problem:

http://au2.php.net/header#45773

He's included a few extra headers along with Content-Length, that may or
may not be required, but probably won't do any harm.

I also noticed that the Content-type being returned for a pdf file from
your site is 'application/.pdf', which is also an issue, but I'm
assuming this isn't the main problem, since you have the correct type in
the code in your email.

> Now this may come as a total surprise to you but it works perfectly in
> firefox but IE produces an error "There was an error opening this
> document. The file does not exist."

I don't have IE anywhere to test with, but best of luck getting this
working.

Cheers, Damien




More information about the General mailing list