Im developing a new plugin. I created a new table in the database.
Now I can save a image in type mediumblob, but I cant recover to put in the web site, only appear binary code.
How i can codificate this binary code to appear the image??
This is the code to save image.
$tipo = $_FILES['vehiculo_inserta_imagen']['type'];
$tamanio = $_FILES['vehiculo_inserta_imagen']['size'];
$imagen_temporal = $_FILES['vehiculo_inserta_imagen']['tmp_name'];
//leer el archivo temporal en binario
$fp = fopen($imagen_temporal, 'r+b');
$data = fread($fp, filesize($imagen_temporal));
fclose($fp);
//escapar los caracteres
$data = mysql_escape_string($data);
And I try to recover using this code:
$usuario = esc_attr($current_user->user_login);
$table_name = $wpdb->prefix . "vehiculos";
$vehiculo= $wpdb->get_row("SELECT * FROM $table_name where matricula = '$usuario'; " );
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire