canvas.php 780 B

123456789101112131415161718192021222324
  1. <?php
  2. // For the ajax post call
  3. echo 'JSON stringified Object: '.$_POST['JSONstrObj'].' was sent to the php file\n';
  4. // For the ajax post call in stringified object data form
  5. $post_data = $_POST['JSONstrObj'];
  6. $canvas_id_data = $_POST['canvas_id'];
  7. $filename = '../json/'.$canvas_id_data.'.json';
  8. $handle = fopen($filename, "w");
  9. if(empty($post_data)) {
  10. echo 'Hmm... I did NOT get any data posted by AJAX.';
  11. }
  12. if(!empty($post_data)) {
  13. echo 'Awesome! Got the JSON info :)';
  14. //$dir = 'YOUR-SERVER-DIRECTORY/files';
  15. //$file = uniqid().getmypid();
  16. //$filename = $dir.$file.'.txt';
  17. // Write to file
  18. fwrite($handle, $post_data);
  19. }
  20. // Close the file
  21. fclose($handle);
  22. ?>