Output file without saving

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

    Output file without saving

    I've seen a few sites that offer this, but I'm not sure how they do it.
    It's a form button, that when pressed, prompts the use to download a
    file. Like if I want my banking records, I select a date range and
    press the button, and it compiles and sends me an excel doc right then.

    What I'd like is to comile and deliver a file in that manner, without
    saving the file to some directory and providing a link. Does anyone
    know how this is done?

    --
    Aaron

  • Ewoud Dronkert

    #2
    Re: Output file without saving

    On 6 May 2005 15:56:50 -0700, AaronV wrote:[color=blue]
    > It's a form button, that when pressed, prompts the use to download a
    > file.[/color]

    See http://php.net/header


    --
    Firefox Web Browser - Rediscover the web - http://getffox.com/
    Thunderbird E-mail and Newsgroups - http://gettbird.com/

    Comment

    • Jason F.

      #3
      Re: Output file without saving

      AaronV wrote:[color=blue]
      > I've seen a few sites that offer this, but I'm not sure how they do it.
      > It's a form button, that when pressed, prompts the use to download a
      > file. Like if I want my banking records, I select a date range and
      > press the button, and it compiles and sends me an excel doc right then.
      >
      > What I'd like is to comile and deliver a file in that manner, without
      > saving the file to some directory and providing a link. Does anyone
      > know how this is done?
      >[/color]

      You send headers that tell the browser to expect something other than
      the normal fare, then stream your dynamic content after. e.g:

      <?php
      $csv = '"name","age "' . "\n";
      $csv .= '"John Doe", 30' . "\n";
      header("Content-type: application/vnd.ms-excel");
      header("Content-disposition: attachment; filename=simple .csv");
      echo $csv;
      ?>

      Comment

      Working...