Decodifica immagine presente nel database
Tramite lo script sottostante riesco ad inserire tranquillamente le immagini nel database.
Codice PHP:
$file_path = $_FILES['userfile']['tmp_name'];
$img = base64_encode(file_get_contents($file_path));
Solo che quando lo decodifico mi restituisce un immensa stringa fatta di lettere e numeri che ovviamente non fanno mostrare l'immagine nel browser.
ecco il pezzo di script
Codice PHP:
$sql = mysqli_query($db, "SELECT immagine, tmp_name FROM utenti WHERE email = '$username'") or die(mysqli_error());
$row = mysqli_fetch_assoc($sql);
$tipo = $row['tmp_name'];
$immagine = $row['immagine'];
base64_decode('$immagine');