Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. var filename = "mysave.txt"
  2. var contents = "xyz";
  3. document.location = "htmlsave.php?filename=" + filename + "&contents=" + contents;
  4.  
  5. if(!isset($_GET)) {
  6. exit(0);
  7. }
  8. $filename = $_GET['filename'];
  9. $contents = $_GET['contents'];
  10.  
  11. header("Pragma: public"); // required
  12. header("Expires: 0");
  13. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  14. header("Cache-Control: private", false); // required for certain browsers
  15. header("Content-Type: application/octet-stream");
  16. header("Content-Disposition: attachment; filename="" . $filename . "";" );
  17. header("Content-Transfer-Encoding: binary");
  18. header("Content-Length: " . strlen($contents));
  19. header("Connection: close");
  20. echo $contents;
  21.  
  22. var i;
  23. var filename = "mysave.txt"
  24. var contents = "";
  25. for(i=0, contents = "";i<10000;i++){
  26. contents += "x";
  27. }
  28. document.location = "htmlsave.php?filename=" + filename + "&contents=" + contents;
  29.  
  30. var filename = "mysave.txt"
  31. var contents = "";
  32. for(i=0, contents = "";i<10000;i++){
  33. contents += "x";
  34. }
  35. dataARR = {
  36. filename: filename,
  37. contents: contents
  38. };
  39. var dataJSON = JSON.stringify(dataARR);
  40. $.ajax({
  41. type: "POST", // This for array
  42. url: "htmlsave.php",
  43. async: true,
  44. cache: false,
  45. crossDomain: false, // This needs to be true for other people
  46. data: { myJson: dataJSON },
  47.  
  48. success: function (data) {
  49. },
  50. error: function (XMLHttpRequest, textStatus, errorThrown) {
  51. }
  52. });
  53.  
  54. if(!isset($_POST) || !isset($_POST['myJson'])) {
  55. exit(0);
  56. }
  57. $dataTotal = json_decode($_POST['myJson'], true);
  58. $filename = $dataTotal['filename'];
  59. $contents = $dataTotal['contents'];
  60.  
  61. header("Pragma: public"); // required
  62. header("Expires: 0");
  63. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  64. header("Cache-Control: private", false); // required for certain browsers
  65. header("Content-Type: application/octet-stream");
  66. header("Content-Disposition: attachment; filename="" . $filename . "";" );
  67. header("Content-Transfer-Encoding: binary");
  68. header("Content-Length: " . strlen($contents));
  69. header("Connection: close");
  70. echo $contents;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement