pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feeddownload binary files to browser
3+ messages / 2 participants
[nested] [flat]
* download binary files to browser
@ 2001-01-07 17:36 Louis Bertrand <louis@bertrandtech.on.ca>
0 siblings, 1 reply; 3+ messages in thread
From: Louis Bertrand @ 2001-01-07 17:36 UTC (permalink / raw)
To: pgsql-php
Hello,
I'm keeping binary documents in PostgreSQL and serving them out with PHP,
but I can't figure out how to make the download seamless for the
non-technical end users.
Let's say I have a table documents (docid integer, docoid oid, name
varchar(256)) with a row (123, 123456, 'blah.xyz') that refers to some
some sort of binary file. docid is the primary key.
What should happen:
user hits URL http://my.site.com/download.php3?docid=123
user sees the download window in his browser and the download window
already has the file name as "blah.xyz".
What happens:
I retrieve the LO and send it out with the MIME type
application/octet-stream and the download window comes up with the file
name "download.php3" regardless of the file name.
What headers can I send to fill in that file name?
Thanks
--Louis <louis@bertrandtech.on.ca>
Louis Bertrand http://www.bertrandtech.on.ca/
Bertrand Technical Services, Bowmanville, ON, Canada
Tel: +1.905.623.1500 Fax: +1.905.623.3852
OpenBSD: Secure by default. http://www.openbsd.org/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: download binary files to browser
@ 2001-01-07 17:41 Stephen van Egmond <svanegmond@bang.dhs.org>
parent: Louis Bertrand <louis@bertrandtech.on.ca>
0 siblings, 1 reply; 3+ messages in thread
From: Stephen van Egmond @ 2001-01-07 17:41 UTC (permalink / raw)
To: Louis Bertrand <louis@bertrandtech.on.ca>; +Cc: pgsql-php
Louis Bertrand (louis@bertrandtech.on.ca) wrote:
> What headers can I send to fill in that file name?
Look at content-disposition in the HTTP RFC.
I do this in a similar application:
header("Content-Disposition: attachment; filename=\"$original_name\"");
it helps on the end-user side if you also report the correct
MIME type for the document (i.e. application/msword).
header("Content-type: $mime");
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: download binary files to browser
@ 2001-01-07 18:12 Louis Bertrand <louis@bertrandtech.on.ca>
parent: Stephen van Egmond <svanegmond@bang.dhs.org>
0 siblings, 0 replies; 3+ messages in thread
From: Louis Bertrand @ 2001-01-07 18:12 UTC (permalink / raw)
To: svanegmond@home.com; +Cc: pgsql-php
Hey, that's probably what I've been looking for!
As for the mime type, I just read that there is a variable in recent
versions of PHP, $userfile_type, that may get sent up by the uploading
browser. I'll store that if availabe to give the user's browser the same
hint.
Thanks
--Louis <louis@bertrandtech.on.ca>
Louis Bertrand http://www.bertrandtech.on.ca/
Bertrand Technical Services, Bowmanville, ON, Canada
Tel: +1.905.623.1500 Fax: +1.905.623.3852
OpenBSD: Secure by default. http://www.openbsd.org/
On Sun, 7 Jan 2001, Stephen van Egmond wrote:
> Louis Bertrand (louis@bertrandtech.on.ca) wrote:
> > What headers can I send to fill in that file name?
>
> Look at content-disposition in the HTTP RFC.
>
> I do this in a similar application:
> header("Content-Disposition: attachment; filename=\"$original_name\"");
>
> it helps on the end-user side if you also report the correct
> MIME type for the document (i.e. application/msword).
>
> header("Content-type: $mime");
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-01-07 18:12 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-07 17:36 download binary files to browser Louis Bertrand <louis@bertrandtech.on.ca>
2001-01-07 17:41 ` Stephen van Egmond <svanegmond@bang.dhs.org>
2001-01-07 18:12 ` Louis Bertrand <louis@bertrandtech.on.ca>
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