Can anyone point me to save to server code example for svg-edit 2.8.1

972 Views Asked by At

I've been working on modifying svg-edit to save to server. With the previous versions I could use the save to server extension - but when I try to implement it on this version - the Save link that's created is non responsive.

1 - Are there new changes to how extensions are invoked in 2.8.1 ? 2 - Is there a viable working sample somewhere out there

And if not - I'd be greatly appreciative of a high level - how to go about building this functionality.

Oh and my server is php.

1

There are 1 best solutions below

0
On

I am trying to do the same, I found this old doc:

http://binoyav.blogspot.com.au/2011/11/svg-edit-saving-files-to-server.html

which I will also post here (just in case the link rots!)

If you'd like to try to get this working, I have created a github repository for testing. https://github.com/zeigerpuppy/Sandstorm-Method-Draw

Instructions follow but they're not working yet!

SVG Edit : Saving files to server

SVG-edit is a fast, web-based, Javascript-driven SVG editor that works in any modern browser. To learn more about SVG-edit, click here . By default, while clicking on the save link given in the menu, the image is opening in new window and user has to manually save the image to user's machine. SVG-edit (version 2.5.1) has given an extension to download the files to user's machine.

To download the file

Open svg-editor.js

In curConfig object, to the extensions array add 'ext-server_opensave.js' to the end. Make sure that ext-server_opensave.js , fileopen.php and filesave.php exist in the svg/extensions directory

To save the file to server

Do the above steps.

Open the extensions/filesave.php and comment out below code

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;

And add the following code at the end

define('DIR_PATH', 'path to the directory with trailing slash');
$fp = fopen(DIR_PATH . $file, 'w+');
fwrite($fp, $contents);
fclose($fp);

Give proper directory path to DIR_PATH constant and give necessary permission to the folder