Added file saving/export ability to server_opensave extension, fixing issue 582
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1625 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
44
editor/extensions/filesave.php
Normal file
44
editor/extensions/filesave.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* filesave.php
|
||||
* To be used with ext-server_opensave.js for SVG-edit
|
||||
*
|
||||
* Licensed under the Apache License, Version 2
|
||||
*
|
||||
* Copyright(c) 2010 Alexis Deveria
|
||||
*
|
||||
*/
|
||||
|
||||
if(!isset($_POST['output_svg']) && !isset($_POST['output_png'])) {
|
||||
die('post fail');
|
||||
}
|
||||
|
||||
$file = '';
|
||||
|
||||
$suffix = isset($_POST['output_svg'])?'.svg':'.png';
|
||||
|
||||
if(isset($_POST['filename']) && strlen($_POST['filename']) > 0) {
|
||||
$file = $_POST['filename'] . $suffix;
|
||||
} else {
|
||||
$file = 'image' . $suffix;
|
||||
}
|
||||
|
||||
if($suffix == '.svg') {
|
||||
$mime = 'image/svg+xml';
|
||||
$contents = rawurldecode($_POST['output_svg']);
|
||||
} else {
|
||||
$mime = 'image/png';
|
||||
$contents = $_POST['output_png'];
|
||||
$pos = (strpos($contents, 'base64,') + 7);
|
||||
$contents = base64_decode(substr($contents, $pos));
|
||||
}
|
||||
|
||||
header("Cache-Control: public");
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Disposition: attachment; filename=" . $file);
|
||||
header("Content-Type: " . $mime);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
|
||||
echo $contents;
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user