Jump to content

PHP file writing


aeroswat

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.