1.保存base64编码的图像
<?php //save your data into a variable - last part is the base64 enpred image $enpred = "data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhE"; //depre the url, because we want to use depred characters to use explode $depred = urldepre($enpred); //explode at ',' - the last part should be the enpred image now $exp = explode(',', $depred); //we just get the last element with array_pop $base64 = array_pop($exp); //depre the image and finally save it $data = base64_depre($base64); $file = 'data.png'; //make sure you are the owner and have the rights to write content file_put_contents($file, $data);2.获取base64编码图像的文件名
$enpred = "data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhE"; $depred = urldepre($enpred); $exp = explode(';', $depred); $exp = explode(':', $exp[0]); $image = array_pop($exp); echo ($image);


