有谁知道如何使用 ASP.NET 将 SVG 保存到 Web 服务器?
我的 asp.net 页面中有一个 SVG 标签,它通过 javacript 进行修改。一旦图像设置为用户喜欢的,我希望用户能够通过按钮将 SVG 图像保存到 Web 服务器。我不知道该怎么做。谁能帮我解决这个问题吗?谢谢。
下面是页面上的精简 html,以说明我的意思:
<body>
<form id="form1" runat="server">
<svg>
..svg content...
</svg>
</form>
</body>
i have an SVG tag in my asp.net page which gets modified via javacript. once the image is set to the user's liking i'd like the user to be able to save the SVG image to the web server via a button. i'm not sure how to go about this. can anyone help me out with this? thanks.
below is the stripped-down html on the page to give an idea of what i mean:
<body>
<form id="form1" runat="server">
<svg>
..svg content...
</svg>
</form>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对 svg 不太熟悉,但是如果您使用 javascript 进行操作,您可以让 javascript 将其作为字符串提供给您,将其填充到隐藏输入中并将其发布到服务器吗? jQuery 也许能够找到它所在的容器并使用 html() 来获取它。
西蒙
I'm not to familiar with svg, but if you're using javascript to manipulate, can you get javascript to give you it as a string, stuff it in an hidden input and post it to the server? jQuery may be able to find the container it's in and use html() to get it.
Simon
西蒙,你让我走上了正轨:
我通过使用 jquery-svg (http:// keith-wood.name/svg.html)来解析 svg 并写入隐藏输入。
然后,我创建了一个 .ashx 处理程序,以在提交时获取隐藏的输入值并将其作为 .jpg 保存到 Web 服务器。
我使用了batik svg工具包(http://xmlgraphics.apache.org/batik/download.cgi< /a>) 将 svg 内容转换为 .jpg 格式。
感谢大家!
simon, you put me on the right track:
i got it to work by using jquery-svg (http://keith-wood.name/svg.html) to parse the svg and write to a hidden input.
i then created an .ashx handler to take the hidden input value on submission and save as a .jpg to the web server.
i used the batik svg toolkit (http://xmlgraphics.apache.org/batik/download.cgi) to convert from the svg content to .jpg format.
thanks to all!