[liphp] Code

Tim Sailer [email protected]
Mon, 16 Jun 2003 11:30:40 -0400


On Mon, Jun 16, 2003 at 11:18:52AM -0400, Christopher R. Merlo wrote:
> On 2003-06-16 08:43 -0400, Tim Sailer <[email protected]> wrote:
> 
> > Take a look at www.nsiinnovations.com, click on the 'Project Ideas'
> > link. You'll see a page come up (served out of the database), and
> > a link for downloading the PDF. I have to force that to be interpreted
> > as something the browser knew about. It's all in the mime-types, the
> > headers you send with the stream. 'plain/x-unknown' should ask you if you
> > want to save or open it.
> 
> Tim:
> Do you wrap the content-type, etc. in HTML tags, or is it plain text?


This is the snippet of code that actually does part of the PDF download:


$query = "select pdf,pdftype,pdfsize from project where projectid=$id"; 

$result = @MYSQL_QUERY($query);

                $data = @MYSQL_RESULT($result,0, "pdf"); 
                $type = @MYSQL_RESULT($result,0, "pdftype");
                $size = @MYSQL_RESULT($result,0, "pdfsize");
                Header("Content-Length: $size");
                Header("Content-type: $type");
                Header("Content-Disposition: attachment; filename=project".$id.".pdf");
                echo $data;

You can use the actual true content type from the stored image, and send
the 'Content-Disposition' header to send the file as an attachment, which 
should ask for open/save with the default name of 'filename='

Hope this helps.

Tim

-- 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> Tim Sailer                       ><  Coastal Internet, Inc.          <<
>> Network and Systems Operations   ><  PO Box 726                      <<
>> http://www.buoy.com              ><  Mastic, NY 11955                <<
>> [email protected]                     ><<<
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<