savefile.php 729 B

123456789101112131415
  1. <?php
  2. // You must first create a file "savefile_config.php" in this extensions directory and do whatever
  3. // checking of user credentials, etc. that you wish; otherwise anyone will be able to post SVG
  4. // files to your server which may cause disk space or possibly security problems
  5. require 'savefile_config.php';
  6. if (!isset($_POST['output_svg'])) {
  7. print "You must supply output_svg";
  8. exit;
  9. }
  10. $svg = $_POST['output_svg'];
  11. $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved').'.svg'; // These characters are indicated as prohibited by Windows
  12. $fh = fopen($filename, 'w') or die("Can't open file");
  13. fwrite($fh, $svg);
  14. fclose($fh);