Create a file and send to user

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

    Create a file and send to user

    I need to create a data file from my PHP for the user to load into their
    word processor as a mail merge data source. Organising the data into rows
    of comma separated values isn't too difficult; what puzzles me is how to
    get that data into a .txt file somewhere on the user's PC.

    How, in general terms, should I go about doing that? Presumably I generate
    and present it in some format which causes the browser to issue a "save as"
    dialog box?
  • sam

    #2
    Re: Create a file and send to user

    <?php

    // The name of the file on the user's pc
    $file_name = "toto.txt";

    header("Content-Type: application/octet-stream");
    header("Content-Disposition: Attachment; filename=$file_ name");

    // $my_data is the string that holds your data
    echo $my_data;

    ?>


    Derek Fountain <nomail@hursley .ibm.com> wrote in message news:<3f04eea4$ 0$23114$5a62ac2 2@freenews.iine t.net.au>...[color=blue]
    > I need to create a data file from my PHP for the user to load into their
    > word processor as a mail merge data source. Organising the data into rows
    > of comma separated values isn't too difficult; what puzzles me is how to
    > get that data into a .txt file somewhere on the user's PC.
    >
    > How, in general terms, should I go about doing that? Presumably I generate
    > and present it in some format which causes the browser to issue a "save as"
    > dialog box?[/color]

    Comment

    Working...