Skip to content

Instantly share code, notes, and snippets.

@matheusnascgomes
Last active May 7, 2018 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matheusnascgomes/385c64148d6c4dfec891d590bd23927b to your computer and use it in GitHub Desktop.
Save matheusnascgomes/385c64148d6c4dfec891d590bd23927b to your computer and use it in GitHub Desktop.
<?php
function base64_to_png ($img, $im_name) {
if ( ($fp = fopen($im_name . '.png', 'wb')) === false ) {
return false;
}
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
if ( fwrite($fp, base64_decode($img)) === false ) {
return false;
}
fclose($fp);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment