时间:2021-07-01 10:21:17 帮助过:14人阅读
function svgToImg($type, $svg, $filename){
clearFile(SAVE_PATH);//删除过期文件
ini_set('magic_quotes_gpc', 'off');
$svg = (string) $svg;
$filename = (string) $filename;
// prepare variables
if (!$filename or !preg_match('/^[A-Za-z0-9\-_ ]+$/', $filename)) {
$filename = 'chart';
}
if (get_magic_quotes_gpc()) {
$svg = stripslashes($svg);
}
// check for malicious attack in SVG
if(strpos($svg,"$output";
echo "Error while converting SVG. ";
}
else {
return $outfile;
}
} else if ($ext == 'svg') {
header("Content-Disposition: attachment; filename=\"$filename.$ext\"");
header("Content-Type: $type");
echo $svg;
} else {
echo "Invalid type";
}
}文件保存到本地,然后就可以随便搞了。
你要是实在嫌安装JAVA环境麻烦,可以直接模拟提交请求官方的导出地址。