PHP Script to save output to a file?

Sharky Forums


Results 1 to 8 of 8

Thread: PHP Script to save output to a file?

  1. #1
    Still Alive spamjedi's Avatar
    Join Date
    Jul 2001
    Location
    The D, Michigan
    Posts
    5,538

    PHP Script to save output to a file?

    I built a PHP web app that generates some complicated text output. I now need to change the app to be able to save that output to a file.

    I have no idea how to do this. I've messed with the header but that doesnt do what I need. I need to save just a specific section of the PHP text output.

    Any thoughts? Or point me in the right direction?
    ||Intel Dual-Core 1.8 GHz||GIGABYTE GA-965P-DS3||EVGA GeForce 8600GTS||
    ||G.SKILL 2GB||Seagate Barracuda 250GB||PHILIPS 20X DVD±R||COOLER MASTER Centurion 5||

    ||A64 3000+||Chaintech SK8T800|Radeon 9800 Pro||
    ||1 gig PC2700||WD 80gig 7200||BenQ 1620 16x4x40x24||XDreamer II||

  2. #2
    om nom nom JDC's Avatar
    Join Date
    Oct 2000
    Location
    gettin' money, gettin' paid
    Posts
    4,432

  3. #3
    Still Alive spamjedi's Avatar
    Join Date
    Jul 2001
    Location
    The D, Michigan
    Posts
    5,538
    will this work to save a file on to the user's remote PC?

    Basically I would like to have a "Save As" button.
    ||Intel Dual-Core 1.8 GHz||GIGABYTE GA-965P-DS3||EVGA GeForce 8600GTS||
    ||G.SKILL 2GB||Seagate Barracuda 250GB||PHILIPS 20X DVD±R||COOLER MASTER Centurion 5||

    ||A64 3000+||Chaintech SK8T800|Radeon 9800 Pro||
    ||1 gig PC2700||WD 80gig 7200||BenQ 1620 16x4x40x24||XDreamer II||

  4. #4
    om nom nom JDC's Avatar
    Join Date
    Oct 2000
    Location
    gettin' money, gettin' paid
    Posts
    4,432
    oh, i believe this will only save on the server.

    http://www.thescripts.com/forum/thread623560.html
    Last edited by JDC; 04-27-2007 at 12:52 PM.

  5. #5
    Still Alive spamjedi's Avatar
    Join Date
    Jul 2001
    Location
    The D, Michigan
    Posts
    5,538
    Hmm Im not sure how to implement that with what I'm trying to do.

    Right now I have all of my desired out put in a string $fileOutput. I'd like the user to be able to save the contents of that string into a text file on their PC.

    Will using the header allow me to do that?
    ||Intel Dual-Core 1.8 GHz||GIGABYTE GA-965P-DS3||EVGA GeForce 8600GTS||
    ||G.SKILL 2GB||Seagate Barracuda 250GB||PHILIPS 20X DVD±R||COOLER MASTER Centurion 5||

    ||A64 3000+||Chaintech SK8T800|Radeon 9800 Pro||
    ||1 gig PC2700||WD 80gig 7200||BenQ 1620 16x4x40x24||XDreamer II||

  6. #6
    om nom nom JDC's Avatar
    Join Date
    Oct 2000
    Location
    gettin' money, gettin' paid
    Posts
    4,432
    what I've done with Coldfusion is to have a link or button point to a seperate page that would handle the output. Using Coldfusion I set the content type and header, then output.

    I think the only downside is that a blank page is opened along with the save as dialog box.

    But it seems like setting the header is the way to go.

  7. #7
    Expensive Sushi
    Join Date
    Jan 2005
    Posts
    15
    What you can do is this:

    Make a folder on your server, write the file to that folder. When the script is done running, output a link to the dir/filename for the user to click on and download that file.

    I did this exact thing at work a few weeks ago. If you need an example of how it's done, email me: [email protected]

  8. #8
    Still Alive spamjedi's Avatar
    Join Date
    Jul 2001
    Location
    The D, Michigan
    Posts
    5,538
    I emailed you aqua.

    I've never worked with headers before, any have a good link that could help me out?
    ||Intel Dual-Core 1.8 GHz||GIGABYTE GA-965P-DS3||EVGA GeForce 8600GTS||
    ||G.SKILL 2GB||Seagate Barracuda 250GB||PHILIPS 20X DVD±R||COOLER MASTER Centurion 5||

    ||A64 3000+||Chaintech SK8T800|Radeon 9800 Pro||
    ||1 gig PC2700||WD 80gig 7200||BenQ 1620 16x4x40x24||XDreamer II||

Posting Permissions

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