Click to See Complete Forum and Search --> : PHP Script to save output to a file?
spamjedi
04-27-2007, 11:52 AM
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?
http://us.php.net/manual/en/function.file-put-contents.php
spamjedi
04-27-2007, 12:26 PM
will this work to save a file on to the user's remote PC?
Basically I would like to have a "Save As" button.
oh, i believe this will only save on the server.
http://www.thescripts.com/forum/thread623560.html
spamjedi
04-27-2007, 04:07 PM
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?
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.
aquanutz
04-28-2007, 05:10 PM
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: aquanutz@gmail.com
spamjedi
04-30-2007, 09:38 AM
I emailed you aqua.
I've never worked with headers before, any have a good link that could help me out?