Topic: Does anyone here use Firebird?

I'd to download an image file that I previously uploaded to my database.
The upload code that i use is this:

Code: PHP

if ($_FILES["file"]["error"] > 0){

        echo "Error: " . $_FILES["file"]["error"] . "

";

    }else{

    $nome = $_FILES["file"]["name"];

    $caminho = $_FILES["file"]["tmp_name"];

    $tam = $_FILES["file"]["size"];

    $fp = fopen($caminho, "rb");

    $buffer = fread($fp, $tam);

    fclose($fp);

    $blh = ibase_blob_create($con);

    ibase_blob_add($blh, $buffer);

    $blobid = ibase_blob_close($blh);

    $sql = "INSERT INTO imagem(nome, imagem) VALUES (?,?)";        

    $sth = ibase_query($con, $sql, $nome, $blobid) or die(ibase_errmsg());

     }

}

and to download (this is were i'm having a huge problem!) the code I found in the internet was:

Code: PHP

<?

    $sql       = "SELECT blob_value FROM table";

    $result    = ibase_query($sql);

    $data      = ibase_fetch_object($result);

    $blob_data = ibase_blob_info($data->BLOB_VALUE);

    $blob_hndl = ibase_blob_open($data->BLOB_VALUE);

    echo         ibase_blob_get($blob_hndl, $blob_data[0]);

?>

But this code didnt work for me.
What I need is to download the image to a temp folder and display it on the browser
can anyone please help me!!

Re: Does anyone here use Firebird?

Code: PHP

header("Content-Type:image/gif\n\n"); // or jpeg/png...



echo $image;

That should do the trick smile

Re: Does anyone here use Firebird?

Store the mime type from $_FILES in the table then you can add it dynamically to the header call too for gifs or jpgs.