SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    generate dynamic text file for download

    Is it possible to generate a text file using text from a database and then make that file available for download? I have a client that wants to display their info. on a web site, as well as provide it in printable and downloadable forms.

    Thanks in advance for any advice!
    Leigh Jones
    Production Director
    Internet Aesthetics

  2. #2
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could always just create the file to a temporary directory and after so much time, just delete it (with php)
    Compwizard
    "There are 10 kinds of people in this world -- those who know binary, and those who don't."

  3. #3
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by compwizard
    you could always just create the file to a temporary directory and after so much time, just delete it (with php)
    How would I go about creating the file? I think that's my major hurdle.
    Leigh Jones
    Production Director
    Internet Aesthetics

  4. #4
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i suggest that you read a tutorial about file manipulation in php: here are some to get you off on your feet:

    http://www.hotscripts.com/PHP/Tips_a..._Manipulation/
    Compwizard
    "There are 10 kinds of people in this world -- those who know binary, and those who don't."

  5. #5
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could have the text file itself be a PHP script by simply setting up your server to parse .txt files for php.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  6. #6
    SitePoint Addict Viral's Avatar
    Join Date
    Nov 2001
    Location
    Washington DC
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aspen
    You could have the text file itself be a PHP script by simply setting up your server to parse .txt files for php.
    You don't have to do any of this. You can have PHP generate just about any type of content, and deliver it in any way a browser knows how. For example:
    PHP Code:
    <? //Generate text file on the fly
     
    header("Content-type: text/plain");
    header("Content-Disposition: attachment; filename=savethis.txt");
     
    // do your Db stuff here to get the content into $content
    print "This is some text...\n";
    print 
    $content;
    ?>
    Save that php script as text.php then in your html file,
    <a href="text.php">Save this</a> - clicking on that link would cuase the save as dialog to pop up...

    I'm a little alte to this question, but hopefully it'll help someone in the future.

    --Viral
    A computer without Windows is like a chocolate cake without mustard.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •