Re: serving up blobs for download
| From: | Rob Montgomery | Date: | Mon, 10 Jul 2000 05:27:02 +0000 |
| Subject: | Re: serving up blobs for download | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5679@lists.php.net to get a copy of this message | ||
Hot diggity damn! That works EXACTLY like I wanted, and for both
browsers too. Thanks a million. As you guessed it was just a
function of adding some additional headers, and also I wasnt using
the "attachment" keyword in the disposition header. For the sake
of completeness to readers, here is the important part of the
example for initiating one-click downloads:
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/octet-stream");
header("Content-Length: $filesize"));
header("Pragma: no-cache");
header("Expires: 0");
I'll have to remember to check weberdev next time :-)
Thanks again,
Rob
Boaz Yahav wrote:
>
> Try looking at this :
>
> How to let a user download a picture by clicking on it instead of needing to
> right click and Save-As.
>
> http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=1562
>
> You can use the general idea to do what you want. IMHO you are simply
> missing
> some headers IE expects cause this works great for me with both IE and NN.
>
> Sincerely
>
> berber
>
> Visit http://www.weberdev.com Today!!!
> To see where PHP might take you tomorrow.
>
> > -----Original Message-----
> > From: Rob Montgomery [mailto:Robert.L.Montgomery@Home.com]
> > Sent: Sunday, July 09, 2000 5:37 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] serving up blobs for download
> >
> >
> > This isnt exactly a PHP question, but...
> >
> > I want users to be able to download (not view with a viewer)
> > pdf files which I have stored as blobs in MySQL, so the php
> > script reads the blob into a variable, then does this:
> >
> > header("content-type: application/octet-stream");
> > header("content-disposition: filename=$filename");
> > echo $blob;
> >
> > With Netscape, this works great, the file save box opens and
> > the filename to save as defaults to my variable $filename.
> >
> > The problem is that IE thinks it should be able to find a
> > program to "view" the content-type of application/octet-stream.
> > Netscape defaults to downloading unknown types, IE just gets
> > confused.
> >
> > Does anyone know how to handle that problem? Is there some
> > other content-type which is specifically used for downloading?
> >
> > Thanks,
> > Rob
> >