Jump to content

Phaser outputing to server text file


Reubencovington
 Share

Recommended Posts

Ok after a bit of fiddling I managed to get it working I think
 

    //File data test    var data = new FormData();    data.append("data" , logevent + " at " + Date() + "\n");    var xhr = new XMLHttpRequest();    xhr.open( 'post', '/output/php/filetest.php', true );    xhr.send(data);

I use a XML http request to send the log data to a simple php script that appends the data to the log file.

 

Php script:

<!DOCTYPE html><?php   if(!empty($_POST['data'])){      $data = $_POST['data'];      $fname = "upload\log.txt";      //appends to the log file and makes sure it can't be written by two programs at once      file_put_contents($fname, $data, FILE_APPEND | LOCK_EX);    }?>
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...