Last active
May 24, 2023 01:30
-
-
Save ogaty/3b1747fe678fee95f43502f03e63d8e3 to your computer and use it in GitHub Desktop.
svg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<form method="POST" enctype="multipart/form-data"> | |
<input type="file" name="svg" id="svg"> | |
<input type="submit"> | |
</form> | |
<?php | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
$svgFile = $_FILES['svg']; | |
$svg = simplexml_load_file($svgFile['tmp_name']); | |
echo '<div style="height: 400px;">'; | |
echo $svg->asXML(); | |
echo '</div>'; | |
$svg->g->text = ''; | |
$newText = $svg->g->addChild('text', 'ううううう'); | |
//$newText->addAttribute('x', '414.412px'); | |
//$newText->addAttribute('y', '369.555px'); | |
foreach ($svg->g->text[0]->attributes() as $key => $val) { | |
$newText->addAttribute($key, $val); | |
} | |
echo '<div style="height: 400px;">'; | |
echo $svg->asXML(); | |
echo '</div>'; | |
file_put_contents('いいいいい.svg', $svg->asXML()); | |
echo 'success'; | |
} | |
?> | |
<script> | |
document.getElementById('svg').addEventListener('change', function(event) { | |
document.querySelector('#img').src = event.target.files[0]; | |
const file = event.target.files[0] | |
const reader = new FileReader() | |
reader.onload = (event) => { | |
// document.querySelector('#img').src = event.target.result; | |
} | |
reader.readAsDataURL(file); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment