如何将svg画布保存到本地文件系统 [英] How to save svg canvas to local filesystem
问题描述
可能有可能使用常规的保存浏览器命令,但它不会只保存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屋!