﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-风清云淡-文章分类-PHP</title><link>http://www.blogjava.net/surroad/category/6923.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 08:09:12 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 08:09:12 GMT</pubDate><ttl>60</ttl><item><title>store and retrieve a (jpg) picture into a blob field ?</title><link>http://www.blogjava.net/surroad/articles/27536.html</link><dc:creator>风清云淡</dc:creator><author>风清云淡</author><pubDate>Wed, 11 Jan 2006 02:33:00 GMT</pubDate><guid>http://www.blogjava.net/surroad/articles/27536.html</guid><wfw:comment>http://www.blogjava.net/surroad/comments/27536.html</wfw:comment><comments>http://www.blogjava.net/surroad/articles/27536.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/surroad/comments/commentRss/27536.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/surroad/services/trackbacks/27536.html</trackback:ping><description><![CDATA[&nbsp;Jun 13th, 2003 15:18<BR>Peter Theill, Andi Worx, Patrick Mahla,<BR><BR><BR>$dbcon = OCILogon($dbUser,$dbPassword,$dbName);<BR>$lob = OCINewDescriptor($dbcon, OCI_D_LOB);<BR>$data = fread(fopen($form_data, "r"), filesize($form_data));<BR>$query = "insert into IMAGE_DATA (";<BR>$query .= "NUM_IMAGEID, STR_IMAGE_TYPE, BLO_IMAGE_DATA";<BR>$query .= ") values (";<BR>$query .= "NUM_ID.NEXTVAL, $form_data_type, EMPTY_BLOB()";<BR>$query .= ") returning BLO_IMAGE_DATA into :img_blob";<BR>$stmt = OCIParse($dbcon,$query);<BR>OCIBindByName($stmt, ':img_blob', &amp;$lob, -1, OCI_B_BLOB);<BR>if (OCIExecute($stmt,OCI_DEFAULT)) {<BR>if($lob-&gt;save($data)){<BR>OCICommit($dbcon);<BR>OCIFreeStatement($stmt);<BR>echo "Blob successfully uploaded\n";<BR>}else{<BR>OCIFreeStatement($stmt);<BR>echo "Couldn't upload Blob\n";<BR>}<BR>}<BR>OCILogoff($dbcon);<BR><BR>--------------------------------------------------------------<BR><BR>If you use this Codesnippet, you can store BLOB to an oracledb!<BR>The next Codesnippet you can view the images!<BR><BR>-------------------------------------------------------------<BR><BR>$dbcon = OCILogon($dbUser,$dbPassword,$dbName);<BR>$query = "select * from IMAGE_DATA where NUM_ID=$id";<BR>$stmt = OCIParse($dbcon, $query);<BR>OCIExecute($stmt, OCI_DEFAULT);<BR>while (OCIFetchInto($stmt, $row, OCI_ASSOC)) {<BR>$data = $row["BLO_IMAGE_DATA"]-&gt;load();<BR>}<BR>$type = OCIResult($stmt,"STR_IMAGE_TYPE");<BR>OCIFreeStatement($stmt);<BR><BR>Header( "Content-type: $type");<BR>echo $data;<BR><BR>cu<BR>AndiWorx
<P>&nbsp;</P><img src ="http://www.blogjava.net/surroad/aggbug/27536.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/surroad/" target="_blank">风清云淡</a> 2006-01-11 10:33 <a href="http://www.blogjava.net/surroad/articles/27536.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>