php 处理base64图片信息

//base64图片处理
function base64_image_content($base64_image_content,$filename,$yname,$savepath){
//匹配出图片的格式
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
$type = $result[2];
$insertfile = ReturnDoTranFilename(null, 0);
$filename = "{$insertfile}.{$type}";
$yname = $savepath . $filename;
if($type=='jpeg'){
$type='jpg';
}
DoChmodFile($yname);
if (file_put_contents($yname, base64_decode(str_replace($result[1], '', $base64_image_content)))){
$pic_o_url = 'https://account.027art.com'.substr($yname,strpos($yname,'/ziyuan'));
return $pic_o_url;
}else{
return false;
}
}else{
return false;
}
}

posted @ 2020-09-04 12:04  宋先生日记  阅读(703)  评论(0编辑  收藏  举报