function up_file_base64($base64_data, $tmp_file, $rename){
  $data = $base64_data; // Your data 'data:image/png;base64,AAAFBfj42Pj4';
  $data = str_replace('data:image/png;base64,', '', $data);
  $data = str_replace(' ', '+', $data);
  $data = base64_decode($data);
  file_put_contents($tmp_file, $data);
  return $rename;
}

$base46_img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAQAAABLCVATAAAAZ0lEQVR4Ae3MMQ4CIRgF4Yn2JHBEzqUWnsflSLBhazYZWvNP+14+ov2i6EnirsTDM19+ZFYVGh9LvRmMSS2Zub1QVfp1P8hLplNhlyqCUVSjCMZSgnGUYBwlGEMJxlKCkVQliqJ/6wSw0UNZdSsg1gAAAABJRU5ErkJggg==";
$rename = date("YmdHis").".jpg";
echo up_file_base64($base46_img, "your_folder/img/". $rename, $rename);

Comment