您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php实现base64转码成图片

2024/6/22 16:46:31发布21次查看
base64图片编码转换,写了个方法。两个参数,一个是base64编码,一个是文件路径
<?php /** * base64转码图片 * @param $base64 * @param string $path * @return bool|string */ function get_base64_img($base64,$path = 'data/upload/sign/'){ if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)){ $type = $result[2]; $new_file = $path.time().".{$type}"; if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64)))){ return $new_file; }else{ return false; } } } ?>
以上就是php实现base64转码成图片的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product