pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adam Witney <awitney@sgul.ac.uk>
To: Frank Bax <fbax@sympatico.ca>
To: pgsql-php <pgsql-php@postgresql.org>
Subject: Re: Automatically opening pdf files stored in a bytea
Date: Tue, 11 Oct 2005 20:47:38 +0100
Message-ID: <BF71D56A.4EF41%awitney@sgul.ac.uk> (raw)
In-Reply-To: <5.2.1.1.0.20051011072754.03649050@pop6.sympatico.ca>

On 11/10/05 12:30 pm, "Frank Bax" <fbax@sympatico.ca> wrote:

> At 06:58 AM 10/11/05, Adam Witney wrote:
>> I have PDF files stored in a bytea field in the database and I want to all
>> the user to click a link on the web page and have the file automatically
>> opened in acrobat (or whatever they have set to read the pdf). It works for
>> most browsers except for in Internet Explorer on windows (surprise
>> surprise!). Here is my code
>> 
>>          header("Content-type: application/pdf");
>>          header('Content-Disposition: attachment;
>> filename="'.$data['filename'].'"');
> 
> 
> Here's mine...
>        if(isset($_SERVER['HTTP_USER_AGENT']) &&
>                        strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
>                header('Content-Type: application/force-download');
>        else
>                header('Content-Type: application/octet-stream');
>        header('Content-Length: '.strlen($this->buffer));
>        header('Content-disposition: attachment; filename="'.$name.'"');
> 
> 
> But on a some systems (both Win98 & WinXP), user must save/open instead of
> open directly - haven't figured out why yet.

From the link sent by Volkan, adding these header lines fixes the problem

 header("Pragma: public");
 header("Expires: 0");
 header("Cache-Control: private");

Thanks for the help guys

Adam


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




view thread (9+ messages)  latest in thread

Message-ID: <BF71D56A.4EF41%awitney@sgul.ac.uk>
Permalink:  ../BF71D56A.4EF41%25awitney@sgul.ac.uk/
Also on:    postgresql.org/message-id/BF71D56A.4EF41%awitney@sgul.ac.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: awitney@sgul.ac.uk, fbax@sympatico.ca
  Subject: Re: Automatically opening pdf files stored in a bytea
  In-Reply-To: <BF71D56A.4EF41%awitney@sgul.ac.uk>
  References: <5.2.1.1.0.20051011072754.03649050@pop6.sympatico.ca> <BF71D56A.4EF41%awitney@sgul.ac.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox