Skip to content

Instantly share code, notes, and snippets.

@olragon
Created April 12, 2017 09:46
Show Gist options
  • Save olragon/cc16bb7e38cd48b7321fa3fbc72f0c75 to your computer and use it in GitHub Desktop.
Save olragon/cc16bb7e38cd48b7321fa3fbc72f0c75 to your computer and use it in GitHub Desktop.
DIGITOP base64 -> server php
if (!empty($_POST['image'])) {
$base64_img = str_replace('data:image/png;base64,', '', $_POST['image']);
base64_to_jpeg($base64_img, './files/hinh_'. uniqid() .'.jpg');
}
function base64_to_jpeg($base64_string, $output_file) {
$ifp = fopen($output_file, "wb");
$data = explode(',', $base64_string);
fwrite($ifp, base64_decode($data[1]));
fclose($ifp);
return $output_file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment