Jay
0
Q:

symfony decrypte images base64 enregistre

<?php

    createImage($_POST['monImageBase64']);

    public function createImage($img)
    {
        $path = "images/";

        $image_parts = explode(";base64,", $img);
        $image_type_aux = explode("image/", $image_parts[0]);
        $image_type = $image_type_aux[1];
        $image_en_base64 = base64_decode($image_parts[1]);
        $file = $path . uniqid() . '.png';

        file_put_contents($file, $image_en_base64);
    }

?>
0

New to Communities?

Join the community