Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14367

Re: PDF Stream

From Chuck Anderson <cycletourist@invalid.invalid>
Newsgroups comp.lang.php
Subject Re: PDF Stream
Date 2014-10-21 01:26 -0600
Organization cycletourist.com
Message-ID <m251qi$tpm$1@dont-email.me> (permalink)
References <m24vut$ueq$2@news.albasani.net>

Show all headers | View raw


Jan Novak wrote:
>
> Hi,
>
> I have the listed code below, what streams a pdf file to the browser 
> client. It works fine. But the resulting temporary PDF File at the 
> client has the name "pdfstream.php". Some clients does not open the 
> pdf file. How can it be named correctly  as pdf?
>
> Jan
>
> // Datei: pdfstream.php
> //includes ...
>     if (isset($_GET)){
>         $id=$_GET['IMG'];
>     } else {
>         die();
>     }
>
>     //hole infos aus der DB
>     $myGet = getPdfForId($id, 1);
>     //hole die Datei aus Pfad
>     $myGet =$cfg['DOCPATH'].$myGet;
>
>     //sende Daten
>     header('Content-Type: application/pdf');
>     $connect_file = fopen($myGet, 'r');
>     $file_stream = fread($connect_file, filesize($myGet));
>     fclose($connect_file);
>     echo $file_stream;

// to download
// header('Content-Disposition: attachment; filename=filename.pdf');

// to open in browser
header('Content-Disposition: inline; filename='filename.pdf');

-- 
*****************************
 Chuck Anderson • Boulder, CO
  http://cycletourist.com
 Turn Off, Tune Out, Drop In
*****************************

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

PDF Stream Jan Novak <repcom@gmail.com> - 2014-10-21 08:53 +0200
  Re: PDF Stream Chuck Anderson <cycletourist@invalid.invalid> - 2014-10-21 01:26 -0600
    Re: PDF Stream Jan Novak <repcom@gmail.com> - 2014-10-21 15:10 +0200

csiph-web