如何将svg画布保存到本地文件系统 [英] How to save svg canvas to local filesystem

查看:721
本文介绍了如何将svg画布保存到本地文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法可以允许用户在使用浏览器在javascript svg画布上创建矢量图形后将其下载到本地文件系统中?对于我来说,SVG是一个全新的领域,所以如果我的措词不准确,请耐心等待。

可能有可能使用常规的保存浏览器命令,但它不会只保存SVG画布,它将保存整个页面。



我相信你最好的选择是使用AJAX,并将整个SVG XML数据作为POST数据发送到服务器脚本,然后让该脚本只发送带有标题 Content-Disposition:attachment的POST数据; (在PHP中,您可以通过 file_get_contents('php :// input')。)


Is there a way to allow a user, after he has created a vector graph on a javascript svg canvas using a browser, to download this file to their local filesystem?

SVG is a total new field for me so please be patient if my wording is not accurate.

解决方案

It might be possible using the regular "Save" browser command, but it won't just save the SVG canvas, it will save the whole page.

I believe your best bet is to use AJAX and send the whole SVG XML data as POST data to a server script, and have that script just send back the POST data with the header Content-Disposition: attachment; filename=yourfile.svg.

(Under PHP, you can get the raw POST contents with file_get_contents('php://input').)

这篇关于如何将svg画布保存到本地文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆