admin管理员组文章数量:1330393
how to do this in php. Do i need to use an php library
<svg
xmlns="" width="360" height="180">
<circle class="little" cx="180" cy="45" r="12"/>
<circle class="little" cx="60" cy="90" r="12"/>
<circle class="little" cx="300" cy="135" r="12"/>
</svg>
Hi i have an xml data above i just want this to save in my folder: images/circle.svg
Is there anyone here can help me. Thank you very much
how to do this in php. Do i need to use an php library
<svg
xmlns="http://www.w3/2000/svg" width="360" height="180">
<circle class="little" cx="180" cy="45" r="12"/>
<circle class="little" cx="60" cy="90" r="12"/>
<circle class="little" cx="300" cy="135" r="12"/>
</svg>
Hi i have an xml data above i just want this to save in my folder: images/circle.svg
Is there anyone here can help me. Thank you very much
Share Improve this question edited Jul 24, 2015 at 8:31 knives22 asked Jul 24, 2015 at 8:25 knives22knives22 3031 gold badge2 silver badges14 bronze badges 10- 1 What do you mean, "i have an svg above"? Is it a file? Do you have it rendered on a client? Is it on a printout in your purse? – Amadan Commented Jul 24, 2015 at 8:28
- im sorry i mean xml data to save as circle.svg file – knives22 Commented Jul 24, 2015 at 8:31
- Of course; SVG is always XML. The point is, where do you have it? – Amadan Commented Jul 24, 2015 at 8:32
- i just want to save it as circle.svg in my folder – knives22 Commented Jul 24, 2015 at 8:33
- 1 I don't know how to ask this any clearer. For the third time, I know that you want to save it, but where is it before that? (I feel like the security guard in Freddy Got Fingered.) – Amadan Commented Jul 24, 2015 at 8:35
2 Answers
Reset to default 6So you've got the data stored as a variable, right? Easy peasy.
file_put_contents('images/circle.svg', $SVGData);
Below code working 100%, hope it will help in your project.
<?php
ob_start();
echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3/2000/svg" xmlns:xlink="http://www.w3/1999/xlink" version="1.1" baseProfile="full" width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>';
$content = ob_get_clean();
if(file_put_contents("circle.svg", $content)) { // Filename for storing purpose
echo "Success";
}
else {
echo "Failed to save file";
}
?>
本文标签: javascripthow to save an svg file in phpStack Overflow
版权声明:本文标题:javascript - how to save an svg file in php - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742225720a2436277.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论