file download three blank lines at start

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

    file download three blank lines at start

    Hi
    I got this info from

    and it works ok with saving the file on the server
    but when I use the
    '2 - To create the file for the user to download'
    the file always starts with three blank lines and
    then the data, when opened with spreadsheet, text
    editor, or pager.

    I have tried both ways and the only real change is
    the addition of the 'header(...)' lines. Any ideas
    how to stop the header(...) lines from spitting
    out newlines?

    The second header line is one line.

    <?php
    header('Content-type: application/octet-stream');
    header('Content-Disposition: attachment;
    filename="filen ame.csv"');
    header('Pragma: no-cache');
    header('Expires : 0');

    snip..

    echo $data;
    ?>

  • John Dunlop

    #2
    Re: file download three blank lines at start

    Tony Lissner wrote:
    [color=blue]
    > http://forums.dreamincode.net/showtopic10131.htm[/color]

    Ditch that and start reading c.l.php instead.

    --
    Jock

    Comment

    • Tony Lissner

      #3
      Re: file download three blank lines at start

      Tony Lissner wrote:[color=blue]
      > Hi
      > I got this info from
      > http://forums.dreamincode.net/showtopic10131.htm
      > and it works ok with saving the file on the server
      > but when I use the
      > '2 - To create the file for the user to download'
      > the file always starts with three blank lines and
      > then the data, when opened with spreadsheet, text editor, or pager.
      >
      > I have tried both ways and the only real change is
      > the addition of the 'header(...)' lines. Any ideas
      > how to stop the header(...) lines from spitting
      > out newlines?
      >
      > The second header line is one line.
      >
      > <?php
      > header('Content-type: application/octet-stream');
      > header('Content-Disposition: attachment; filename="filen ame.csv"');
      > header('Pragma: no-cache');
      > header('Expires : 0');
      >
      > snip..
      >
      > echo $data;
      > ?>[/color]

      Turns out it was some blank lines before
      the first <?php in a few of the included
      files.

      It works fine now.

      Comment

      Working...