download binary files to browser
download binary files to browser
От:
Louis Bertrand <louis@bertrandtech.on.ca>
Дата:
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 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/
Re: download binary files to browser
От:
Stephen van Egmond <svanegmond@bang.dhs.org>
Дата:
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");
Re: download binary files to browser
От:
Louis Bertrand <louis@bertrandtech.on.ca>
Дата:
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 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");
>
>