Hi,

I'm trying to store an image - getting by HTTP-Post - in a Sybase
iAnywhere-Database.

I'm using the Unified ODBC functions to connect to the database.

The following function should store the image-file:

function ab_insert_file ( $connection_id, $document_id)
{
        if ($_FILES['FILE']['size'] > 0 )
        {
        //move_uploaded_file($_FILES['FILE']['tmp_name'],'c:\tmp\file1.gif'); //
just tried, if the upload works
        $mime_type = 'IMAGE/GIF';
        $fhandle = fopen($_FILES['FILE']['tmp_name'],'r');
        $blob_data = fread($fhandle, filesize($_FILES['FILE']['tmp_name']));
        $data = bin2hex( $blob_data );
        $insert = "insert into document_file
                                (document_id, filename, data, file_date, mime_type) 
values
                                ($document_id, '".$_FILES['FILE']['name']."', 
0x".$data.", NULL,
'$mime_type')";
        ab_insert_db($connection_id, $insert); // function for inserting the
statement
        }
}

The fileupload works fine. But if i try to face the image, I only get some
fragments of it (the first part, only).

The output-function reads as follows:

<?php
$select = "select data, mime_type from document_file where document_file_id
= $document_file_id";
$Query_ID = odbc_exec($connection_id, $select);
// change to ODBC_BINMODE_CONVERT for comparison
odbc_binmode($Query_ID, ODBC_BINMODE_RETURN);
$Images = odbc_result($Query_ID, 1);
echo $Images;
?>

Any Idea?

Thanks :-))

Markus

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to