$imageData = $node->getImageStringData(true);
//添加图片html显示标头
$content = '';
$imageData = 'data:' . $node->getImageType() . ';base64,' . $imageData;
if(preg_match('/^(data:\s*image\/(\w+);base64,)/', $imageData,$result)){
$type = $result[2];
$path = "uploads/companyDocument/20240223/";
$path = $path.time().".{$type}";
if (file_put_contents($path, base64_decode(str_replace($result[1], '', $imageData)))){
return $path;
}else{
halt(1);
}
}
base64图片字符串保存为图片
于 2024-02-23 19:27:51 首次发布