PHP code example of decmuc / svgsanitizer
1. Go to this page and download the library: Download decmuc/svgsanitizer library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
decmuc / svgsanitizer example snippets
decMuc\SvgSanitizer\SvgSanitizer;
// SVG-Datei einlesen
$svg = file_get_contents('upload/logo.svg');
// Sicherheitsprüfung & Reinigung durchführen
$result = SvgSanitizer::isSafe($svg);
if ($result['status']) {
// SVG kann sicher weiterverarbeitet werden
file_put_contents("cleaned.svg", $result['svg']);
echo 'SVG ist sicher!';
} else {
// Datei ablehnen oder protokollieren
echo $result['msg'];
}