Re: Automatically opening pdf files stored in a bytea

From: Adam Witney <awitney(at)sgul(dot)ac(dot)uk>
To: Frank Bax <fbax(at)sympatico(dot)ca>, pgsql-php <pgsql-php(at)postgresql(dot)org>
Subject: Re: Automatically opening pdf files stored in a bytea
Date: 2005-10-12 12:28:37
Message-ID: BF72C005.4F002%awitney@sgul.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php


I sent this but it didn't seem to appear....

> 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.

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Leodan Vega Izaguirre 2005-10-12 13:11:29 Re: Set Privileges on All Tables - Wrong List - Sorry
Previous Message Christopher Kings-Lynne 2005-10-12 01:29:04 Re: Automatically opening pdf files stored in a bytea field