How to transform an image that I got from an input to base 64 with php?

0

I would like to transform a base64 image obtained from an input. But in doing so I print "ZGVzY2FyZ2ExLmpwZw ==" or something similar with each image I try. How do I make it so that I really get the image in base 64?

HTML:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

    <form role="form" action="imagen.php" method="post" name="productoform">
        <input type="file" name="imagen" required class="form-control">
        <input type="submit" name="sub" value="Base64">
    </form>


</body>
</html>

PHP:

<?php
$imagen = utf8_decode($_POST['imagen']);
$imdata = base64_encode($imagen);

echo $imdata;
?>
    
asked by Samuel Viema 03.12.2018 в 13:59
source

0 answers