You are here: Re: putting a word doc in a mysql db? « PHP Programming Language « IT news, forums, messages
Re: putting a word doc in a mysql db?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация