Created
April 12, 2017 09:46
-
-
Save olragon/cc16bb7e38cd48b7321fa3fbc72f0c75 to your computer and use it in GitHub Desktop.
DIGITOP base64 -> server php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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