X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 71AA6D7260 for ; Tue, 11 Oct 2005 22:26:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47612-05 for ; Wed, 12 Oct 2005 01:26:26 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 010A6D6DB0 for ; Tue, 11 Oct 2005 22:26:27 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 252EC2505A; Wed, 12 Oct 2005 09:26:30 +0800 (WST) Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 51A4D24FF7; Wed, 12 Oct 2005 09:26:25 +0800 (WST) Message-ID: <434C66E0.8060801@familyhealth.com.au> Date: Wed, 12 Oct 2005 09:29:04 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Adam Witney Cc: pgsql-php Subject: Re: Automatically opening pdf files stored in a bytea field References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-familyhealth-MailScanner-Information: Please contact the ISP for more information X-familyhealth-MailScanner: Found to be clean X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/19 X-Sequence-Number: 3287 I'm not 100% sure you need the pg_unescape_bytea - I thought that was already done automatically? Chris Adam Witney wrote: > Hi, > > This may be off-topic as regards the database aspect, but im sure people on > this list must come across this problem. > > 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 > > $sql_data = "SELECT filename, file_data FROM dba_suppl WHERE dba_suppl_id = > ".$dba_suppl_id.";"; > > if($stat2 = execute($sql_data)) > { > if($rows = pg_numrows($stat2)) > { > $data = pg_fetch_array($stat2, 0); > > header("Content-type: application/pdf"); > header('Content-Disposition: attachment; > filename="'.$data['filename'].'"'); > > echo pg_unescape_bytea($data['file_data']); > } > } > > If I click it it opens acrobat but acrobat gives an error. If I right click > the link and save to disk I can open the file from there no problem. As I > say, on my mac and on FireFox on windows it does the right thing... Its just > IE on windows! > > Is there something I am forgetting to do here? Or is it just IE and there is > no way around it?? > > Thanks for any help > > Adam > >