PHP保存base64图片到本地
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2019-11-17 23:16:42
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章
保存base64到本地
$base64Data = ''; if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64Data, $result)) { $type = $result[2]; $new_file = "./test.{$type}"; if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64Data)))) { echo '新文件保存成功:', $new_file; } }