Save base64-encoded image in PHP
<?php
function saveImage($base64img){
define('UPLOAD_DIR', '../uploads/');
$base64img = str_replace('data:image/jpeg;base64,', '', $base64img);
$data = base64_decode($base64img);
$file = UPLOAD_DIR . '123123123.jpg';
file_put_contents($file, $data);
}
// your encoded sting
saveImage('data:image/png;base64,BBBFBfj42Pj4');
?>
Comments
Post a Comment