[PHP-DB] Storing files in database using ODBC

2004-02-16 Thread Markus Müller
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:



Any Idea?

Thanks :-))

Markus

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



RE: [PHP-DB] storing files in database

2003-03-18 Thread Beverly Steiner
Michiel,

You could try storing them in the longtext (text) or longblob (binary)
fields.  Search at www.mysql.com for more information about the differences
between them.  Unless you need to search on the data within MySQL, storing
files (especially long ones) in the database usually isn't the best
solution.

Bev

--
Beverly Steiner
[EMAIL PROTECTED]


-Original Message-
From: Michiel van Heusden [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 8:25 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] storing files in database


is there any possibility using PHP 4 to store entire files as a database
field in a MySQL database?
and if so, does anybody know a way, or a tutorial describing this?

thanks
michiel



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


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



[PHP-DB] storing files in database

2003-03-18 Thread Michiel van Heusden
is there any possibility using PHP 4 to store entire files as a database
field in a MySQL database?
and if so, does anybody know a way, or a tutorial describing this?

thanks
michiel



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