//图片base64反处理 function base64_image_content($base64_image_content,$path){ //匹配出图片的格式 if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){ $type = $result[2]; $image_name = md5(uniqid(rand())).".jpg"; if (!file_exists($path)){ mkdir ($path,0644,true); } $new_file = $path."/".$image_name; if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){ return $image_name; }else{ return ''; } }else{ return ''; } } //图片转码显示 function picBase($picArr){ $img = explode(",",$picArr); $imgArr = []; $imgStr = ''; foreach($img as $value){ $Fjnrs = file_get_contents('../uploads/pics/'.$value); $imgArr = "data:image/jpg;base64,".base64_encode($Fjnrs); $imgStr .= '<img class="imgs" style="width:100px;height:150px" src='.$imgArr.'>'; } return $imgStr; }
base64
最新推荐文章于 2021-08-05 19:12:11 发布