|
Posted by Robert Lummert on 01/14/06 12:31
Marc,
you can put your binary data into a blob field (say named doc) using
straight sql just like:
$sql = 'update mytable set doc=0x';
$fh = fopen($_FILES['userfile']['tmp_name'],'rb');
while(true) {
$chunk = unpack('H*chunk',fread($fh,512));
$sql .= $chunk['chunk'];
if(strlen($chunk['chunk'])<512) break;
}
fclose($fh);
where $_FILES['userfile']['tmp_name'] is the file coming with a post
request.
But this is just appropriate for personal use as it is consuming lots of
ram and costs performance on both sides, the php engine and the
database. Make also sure that driver specific settings allow huge query
strings.
Other solutions depend on the database and databasedriver
you use but should be much more efficient.
Cheers,
robert
Navigation:
[Reply to this message]
|