aeroswat Posted June 23, 2010 Share Posted June 23, 2010 I'm curious is there a way to take everything that is echo'd on a php file and have it sent to a file instead that is stored on the server? I have done this with a header for saving to the users computer but I don't know if there is a way to save the output to a file on the server instead Link to comment https://forums.phpfreaks.com/topic/205662-php-file-writing/ Share on other sites More sharing options...
samoht Posted June 23, 2010 Share Posted June 23, 2010 The answer is of course - yes. But it would be nice if you had more specifics so that we could help you achieve what you want. For example, you ask if you can save output to a file on the server. What kind of file .txt or something else? Do you want to save outputed data to a database for later retrieval etc? Link to comment https://forums.phpfreaks.com/topic/205662-php-file-writing/#findComment-1076228 Share on other sites More sharing options...
aeroswat Posted June 23, 2010 Author Share Posted June 23, 2010 The answer is of course - yes. But it would be nice if you had more specifics so that we could help you achieve what you want. For example, you ask if you can save output to a file on the server. What kind of file .txt or something else? Do you want to save outputed data to a database for later retrieval etc? Basically I have a script that I use to download a sql dump of my database for a backup on the computer but I also want to download automatic backups to the server as well (seems like a stupid idea but I want to do it) I have configured the disposition header to download the sql file as an attachment but I dont know how to do the same thing and put the file instead on the server. Link to comment https://forums.phpfreaks.com/topic/205662-php-file-writing/#findComment-1076231 Share on other sites More sharing options...
aeroswat Posted June 23, 2010 Author Share Posted June 23, 2010 Further studying has shown me a possible solution. Could I do something like this? $filename = "dump.sql"; $handle = fopen($filename, 'x+'); ob_start(); somefunction(); fwrite($handle, ob_end_flush()); fclose($handle); somefunction() { echo "some stuff to go in the file \n"; echo "some more stuff"; } Link to comment https://forums.phpfreaks.com/topic/205662-php-file-writing/#findComment-1076236 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.