To download a pdf file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pablito

    #1

    To download a pdf file

    Hi at all

    I want that a visitor of my internet site download a pdf file (12 mega
    length) without display it
    To make that I tryed many scripts but they do not work
    The most simply script that I used is:
    <?php
    header("Content-type: application/pdf");
    header("Content-Disposition: attachment; filename=newspa per.pdf");
    ?>
    It work!!!
    Infact it save the file but not the full file that is 12 M. but only few
    Kb.an after isd I open the file it make error.
    Then I tryed:
    <?php
    header("Content-type: application/pdf");
    header("Content-Disposition: attachment; filename=newspa per.pdf");
    header("Content-Length: ".filesizenewsp aper.pdf);

    ?>

    Then I tryed:
    <?
    $File="newspepa r.pdf";
    header("Pragma: public");
    header("Expires : Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: must-revalidate");
    header("Content-type: application/pdf");
    header("Content-Length: ".filesize($fil e));
    header("Content-disposition: inline; filename=$file" );
    header("Accept-Ranges: ".filesize($fil e));
    readfile($file) ;
    exit();
    ?>
    but they make Nothing

    Please how can I solve the problem?

    Thank in advance
    Pablito


  • Pablito

    #2
    Re: To download a pdf file

    At last I used this:

    <?
    $File="newspape r.pdf";
    ini_set('zlib.o utput_compressi on','Off');
    header("Pragma: public");
    header('Expires : ' . gmdate('D, d M Y H:i:s', time()+24*60*60 ) . ' GMT');
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: must-revalidate");
    header("Content-type: application/pdf");
    header("Content-Length: ".filesize($fil e));
    header("Content-disposition: inline; filename=$file" );
    header("Accept-Ranges: ".filesize($fil e));
    readfile($file) ;
    exit();
    ?>

    that do not work like others

    Pablito


    Comment

    • Chuck Anderson

      #3
      Re: To download a pdf file

      Pablito wrote:
      At last I used this:
      >
      <?
      $File="newspape r.pdf";
      ini_set('zlib.o utput_compressi on','Off');
      header("Pragma: public");
      header('Expires : ' . gmdate('D, d M Y H:i:s', time()+24*60*60 ) . ' GMT');
      header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
      header("Cache-Control: must-revalidate");
      header("Content-type: application/pdf");
      header("Content-Length: ".filesize($fil e));
      header("Content-disposition: inline; filename=$file" );
      header("Accept-Ranges: ".filesize($fil e));
      readfile($file) ;
      exit();
      ?>
      >
      that do not work like others
      >
      Pablito
      >
      >
      >
      Is this still a question?

      If so, here's what works for me:

      header('Content-Description: File Transfer');
      header('Content-Type: application/pdf');
      header('Content-Length: ' . filesize($file) );
      header('Content-Disposition: attachment; filename=' . basename($file) );

      readfile($file) ;


      --
      *************** **************
      Chuck Anderson • Boulder, CO

      *************** **************

      Comment

      Working...