|
Home > Archive > PHP with PostgreSQL > October 2005 > Re: Automatically opening pdf files stored in a bytea
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Automatically opening pdf files stored in a bytea
|
|
| Frank Bax 2005-10-27, 8:14 am |
| 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& #91;'HTTP_USER_AGENT
']) &&
strpos($_SERVER& #91;'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.
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
| |
| operationsengineer1@yahoo.com 2005-10-27, 8:14 am |
| --- Frank Bax <fbax@sympatico.ca> wrote:
> At 06:58 AM 10/11/05, Adam Witney wrote:
> database and I want to all
> the file automatically
> read the pdf). It works for
> windows (surprise
>
>
> Here's mine...
> if(isset($_SERVER& #91;'HTTP_USER_AGENT
']) &&
>
> strpos($_SERVER& #91;'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.
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
i have had very good success storing links to pdf
files in the database and storing the actual files in
the locations pointed to by the link.
my application is work instructions - i have a naming
convention that i use so once you know the part
number, you know the name of the pdf if it exists.
i have two types of pdf documents and a name prefix
differentiates them from each other.
both firefox and ie will open these pdfs as expected.
if this approach makes sense for your application, you
may want to try it.
____________________
______________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
| |
| Adam Witney 2005-10-27, 8:14 am |
| On 11/10/05 12:30 pm, "Frank Bax" <fbax@sympatico.ca> wrote:
> At 06:58 AM 10/11/05, Adam Witney wrote:
>
>
> Here's mine...
> if(isset($_SERVER& #91;'HTTP_USER_AGENT
']) &&
> strpos($_SERVER& #91;'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.
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
| |
| Adam Witney 2005-10-27, 8:14 am |
|
I sent this but it didn't seem to appear....
> At 06:58 AM 10/11/05, Adam Witney wrote:
>
>
> Here's mine...
> if(isset($_SERVER& #91;'HTTP_USER_AGENT
']) &&
> strpos($_SERVER& #91;'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.
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
|
|
|
|
|