pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adam Witney <awitney@sgul.ac.uk>
To: pgsql-php <pgsql-php@postgresql.org>
Subject: Automatically opening pdf files stored in a bytea field
Date: Tue, 11 Oct 2005 11:58:30 +0100
Message-ID: <BF715966.4EE66%awitney@sgul.ac.uk> (raw)


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


-- 
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: <BF715966.4EE66%awitney@sgul.ac.uk>
Permalink:  ../BF715966.4EE66%25awitney@sgul.ac.uk/
Also on:    postgresql.org/message-id/BF715966.4EE66%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
  Subject: Re: Automatically opening pdf files stored in a bytea field
  In-Reply-To: <BF715966.4EE66%awitney@sgul.ac.uk>
  References: <BF715966.4EE66%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