php将base64编码转换为图片保存至指定位置
$base64为图片的编码字符串
preg_match("/^(data:s*image/(w+);base64,)/", $base64, $result);
$type = $result[2]; //获取图片的类型jpg png等$name = ”xxxx".".$type; //图片重命名
$savepath = ‘C:/".$name; //图片保存目录
file_put_contents($savepath, base64_decode(str_replace($result[1], "", $base64))); //对图片进行解析并保存
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: PHP将Base64图片转换为本地图片并保存
- 下一篇: php将base64格式的图片保存在指定目录