Last change
on this file since 29468 was 29468, checked in by sjs49, 9 years ago |
Initial commit for editor.method.ac for flag design
|
-
Property svn:executable
set to
*
|
File size:
994 bytes
|
Line | |
---|
1 | <?php
|
---|
2 | /*
|
---|
3 | * filesave.php
|
---|
4 | * To be used with ext-server_opensave.js for SVG-edit
|
---|
5 | *
|
---|
6 | * Licensed under the Apache License, Version 2
|
---|
7 | *
|
---|
8 | * Copyright(c) 2010 Alexis Deveria
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | if(!isset($_POST['output_svg']) && !isset($_POST['output_png'])) {
|
---|
13 | die('post fail');
|
---|
14 | }
|
---|
15 |
|
---|
16 | $file = '';
|
---|
17 |
|
---|
18 | $suffix = isset($_POST['output_svg'])?'.svg':'.png';
|
---|
19 |
|
---|
20 | if(isset($_POST['filename']) && strlen($_POST['filename']) > 0) {
|
---|
21 | $file = $_POST['filename'] . $suffix;
|
---|
22 | } else {
|
---|
23 | $file = 'image' . $suffix;
|
---|
24 | }
|
---|
25 |
|
---|
26 | if($suffix == '.svg') {
|
---|
27 | $mime = 'image/svg+xml';
|
---|
28 | $contents = rawurldecode($_POST['output_svg']);
|
---|
29 | } else {
|
---|
30 | $mime = 'image/png';
|
---|
31 | $contents = $_POST['output_png'];
|
---|
32 | $pos = (strpos($contents, 'base64,') + 7);
|
---|
33 | $contents = base64_decode(substr($contents, $pos));
|
---|
34 | }
|
---|
35 |
|
---|
36 | header("Cache-Control: public");
|
---|
37 | header("Content-Description: File Transfer");
|
---|
38 | header("Content-Disposition: attachment; filename=" . $file);
|
---|
39 | header("Content-Type: " . $mime);
|
---|
40 | header("Content-Transfer-Encoding: binary");
|
---|
41 |
|
---|
42 | echo $contents;
|
---|
43 |
|
---|
44 | ?> |
---|
Note:
See
TracBrowser
for help on using the repository browser.