[PHP] Correct headers for I.E. to open PDF?

2004-09-03 Thread Paul Danko
I have searched the net, and found tons of developers with different
solutions to this problem, none of which I have found to work. 
 
What should the headers be for a client to download a PDF document and
have it open using adobe i.e. pluggin??
 
Here is code I am using, it works on some versions of I.E., but not all:
 
 
$pdfdoc = $__BASE_PDF_BUILD_DIRECTORY.$_GET['FID'];

$filesize = filesize($pdfdoc);
header(Pragma: );
header(Expires: 0); 
header(Cache-Control: must-revalidate, post-check=0,pre-check=0);
header(Content-type: application/pdf);
header(Content-Length: .$filesize);
header(Content-Disposition: inline; filename=FILE.pdf);
header(Content-Transfer-Encoding: binary);
header(Accept-Ranges: bytes);

readfile($pdfdoc);
exit();
 
 
Why isn't it working?
 
Thanks,
 
-Paul
 


Re: [PHP] Correct headers for I.E. to open PDF?

2004-09-03 Thread Matt M.
 $pdfdoc = $__BASE_PDF_BUILD_DIRECTORY.$_GET['FID'];
 
 $filesize = filesize($pdfdoc);
 header(Pragma: );
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0,pre-check=0);
 header(Content-type: application/pdf);
 header(Content-Length: .$filesize);
 header(Content-Disposition: inline; filename=FILE.pdf);
 header(Content-Transfer-Encoding: binary);
 header(Accept-Ranges: bytes);
 
 readfile($pdfdoc);
 exit();
 
 Why isn't it working?

IE can seems to ignore these headers some times (I think it might have
something to do with the .php extension).  I have had success creating
the file and saving it with .pdf as the extension then redirecting to
that file.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Correct headers for I.E. to open PDF?

2004-09-03 Thread Jim Grill
 I have searched the net, and found tons of developers with different
 solutions to this problem, none of which I have found to work.

 What should the headers be for a client to download a PDF document and
 have it open using adobe i.e. pluggin??

 Here is code I am using, it works on some versions of I.E., but not all:


 $pdfdoc = $__BASE_PDF_BUILD_DIRECTORY.$_GET['FID'];

 $filesize = filesize($pdfdoc);
 header(Pragma: );
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0,pre-check=0);
 header(Content-type: application/pdf);
 header(Content-Length: .$filesize);
 header(Content-Disposition: inline; filename=FILE.pdf);
 header(Content-Transfer-Encoding: binary);
 header(Accept-Ranges: bytes);

 readfile($pdfdoc);
 exit();


 Why isn't it working?

 Thanks,

 -Paul

If you attempting this over a secure connection (which I assume is why
you're having so much trouble) I.E. can be pretty gay. If it is over a
secure connection, it has to do with I.E. not being able to write to cache
or something. I forgot -- I ran into this a while back. If it's not over a
secure connection, I.E. is still gay. :-)

Try this:

header('Content-Type: application/pdf');
header('Content-Length: '.$filesize);
header('Content-Disposition: inline; filename=FILE.pdf');
header(Cache-Control: private);
header(Pragma: public);

readfile($pdfdoc);
exit();

When all else fails - force a download:

if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) 
strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE'))
header('Content-Type: application/force-download');
else
header('Content-Type: application/octet-stream');
header('Content-Length: '.$filesize);
header('Content-Disposition: inline; filename=FILE.pdf');
header(Cache-Control: private);
header(Pragma: public);


Jim Grill

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Correct headers for I.E. to open PDF?

2004-09-03 Thread Octavian Rasnita
This has nothing to do with PHP or the server, but with the way the client
computer is configured.
If the user doesn't want to open a .pdf file in the browser but to be
prompted for saving the file, that's the way he will have it.
...fortunately.

Teddy

Teddy

- Original Message - 
From: Paul Danko [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 03, 2004 10:05 PM
Subject: [PHP] Correct headers for I.E. to open PDF?


I have searched the net, and found tons of developers with different
solutions to this problem, none of which I have found to work.

What should the headers be for a client to download a PDF document and
have it open using adobe i.e. pluggin??

Here is code I am using, it works on some versions of I.E., but not all:


$pdfdoc = $__BASE_PDF_BUILD_DIRECTORY.$_GET['FID'];

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Correct headers for I.E. to open PDF?

2004-09-03 Thread Curt Zirzow
* Thus wrote Paul Danko:
  
 What should the headers be for a client to download a PDF document and
 have it open using adobe i.e. pluggin??
  
 Here is code I am using, it works on some versions of I.E., but not all:
  
  
 $pdfdoc = $__BASE_PDF_BUILD_DIRECTORY.$_GET['FID'];
 
 $filesize = filesize($pdfdoc);
 header(Pragma: );
 header(Expires: 0); 
 header(Cache-Control: must-revalidate, post-check=0,pre-check=0);
 header(Content-type: application/pdf);

This can be difiult to control sometimes.  You could send a header
like so:

  header(Content-Type: application/octet-stream);

Will generally do the trick.  There are times when i've seen IE
behave in very wierd, no matter the content-type, for example,
accessing a url like:
  
  http://domain.com/a/file.php?param=1bar=.jpg

IE may attempt to display the thing in the browser because it saw
the .jpg extension, even though I sent a headers that should
have prompted a download.

IE has gotten better but it still all depends on how the person has
their computer set up to handle content types (IE tries to be too
smart sometimes.)


Curt
-- 
The above comments may offend you. flame at will.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php