How do I save an image on a path by searching from an Oracle database?

2

I'm trying with the PHP GD library, like this:

<?php
$con = oci_connect('root', '123', '172.16.1.100/DB');
$stmt = oci_parse($con, "SELECT Nome, Imagem FROM Tabela where ID = '1'");
oci_execute($stmt);

$row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS);
if (!$row) {
    header('Status: 404 Not Found');
} else {
    $assinatura = $row['IMAGEM'];
    header("Content-type: image/png");
    $imagem = imagecreatefrompng($assinatura);
    imagepng($imagem,"img-".$row['NOME'].".png");
    imagedestroy($imagem);
}
?>

But it does not save. If I give a print $ signature it appears the right image.

    
asked by anonymous 30.07.2018 / 22:47

1 answer

1

I managed to solve it, not the way I wanted it, but it worked!

First I converted the special characters with base64_encode($assinatura) and inserted in the other Base (MySQL). Then I retrieved this data with

print base64_decode($assinatura); 
header("Content-type: image/png");

If someone else has another solution ..

    
31.07.2018 / 21:43