
kanikase
Préstamo
Ómicron
Programador
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Hola, necesito ayuda, quiero hacer una pequeña web de uso personal, para pasar las imagenes a base64, ya lo tengo, pero no quiero seleccionar el directorio de la imagen directo del código, si no de un formulario, alguien me puede ayudar, esto es lo que tengo hasta ahora.
PHP:
<title>Crear imagen base64</title>
<div style="width:520px;border:1px solid black;padding:8px;margin:8px 15px 8px 0;">
<form enctype="multipart/form-data" action="" method="post"><div style='margin-bottom:15px'>
<input name="uploadedfile" type="file" style="width:400px;" />
<input type="submit" value="Subir archivo" /></div>
<?php
$file = 'head.png';
$tipo = pathinfo($file,PATHINFO_EXTENSION);
$datos = file_get_contents($file);
$base64 = 'data:image/'.$tipo.';base64,'.base64_encode($datos);
echo '<img src="'.$base64.'" width="100" height="100" /><br><br><textarea onclick="this.select()" style="width:100%;height:200px;">'.$base64.'</textarea>';
?>