Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 4, 2021 19:33
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 parzibyte/334e6b9b28985193a002d78b3cefc094 to your computer and use it in GitHub Desktop.
Save parzibyte/334e6b9b28985193a002d78b3cefc094 to your computer and use it in GitHub Desktop.
<?php
$imagenCodificada = $_POST["imagen"];
$imagenCodificadaLimpia = str_replace("data:image/png;base64,", "", $imagenCodificada);
$imagenDecodificada = base64_decode($imagenCodificadaLimpia);
$nombreImagenGuardada = "imagen_" . uniqid() . ".png";
file_put_contents($nombreImagenGuardada, $imagenDecodificada);
echo json_encode($nombreImagenGuardada);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment