|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
//store.php <HTML> <HEAD><TITLE>Store binary data into Oracle Database</TITLE></HEAD> <BODY> <?php // 假如提交了表单,代码将被执行: dl("php_oci8.dll"); $conn = OCILogon("scott","tiger"); if ($submit) { echo "File name: <b>$userfile_name</b><br>/n"; echo "File size: <b>$userfile_size</b><br>/n"; $hwsize = GetImageSize($userfile ); $w = $hwsize[0]; $h = $hwsize[1]; echo "Image width: <b>$w</b><br>/n"; echo "Image height: <b>$h</b><br>/n"; $ImgType = strtolower(substr( strrchr( $userfile_name, "." ), 1 ) ); if ($ImgType == "jpg") $ImgType = "jpeg"; echo "Image type: <b>$ImgType</b><br>/n"; echo "Created date; <b>".date(\\'Y-m-d\\')."</b><br>/n"; $sql = "insert into Picture (PicId, UserName, Width, Height, ImgSize, ImgType, Created, Image, FileName, Description) values(PicturePicId.nextval, \\'$username\\', $w, $h, \\'$userfile_size\\', \\'$ImgType\\', TO_DATE(\\'".date(\\'Y-m-d\\')."\\',\\'YYYY-MM-DD\\'), EMPTY_BLOB(), \\'$userfile_name\\', \\'$description\\') returning Image into :Image"; echo "<pre>$sql</pre>"; $stmt = OCIParse($conn, $sql ); $Image = OCINewDescriptor($conn ); OCIBindByName($stmt, ":Image", $Image, -1, SQLT_BLOB ); if (!OCIExecute($stmt, OCI_DEFAULT)) { echo "Execution failed"; exit(1); } $fp = fopen($userfile, "r" ); $Image->save(fread($fp, filesize($userfile ) ) ); fclose($fp ); OCICommit($conn ); OCIFreeStatement($stmt ); } else { ?> <form method="post" action=" <?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> File Description:<br> <input type="text" name="description" size="40"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000"> <br>File to upload/store in database:<br> <input type="file" name="userfile" size="40"> <p><input type="submit" name="submit" value="submit"> </form> <?php } ?> </BODY> </HTML> //display.php <?php /* Purpose: Display an image from \\'Picture\\' table */ dl("php_oci8.dll"); $conn = OCILogon("scott","tiger"); $stmt = OCIParse($conn, "select Image, ImgType from Picture where picid=23" ); OCIExecute($stmt); @OCIFetchInto($stmt, &$result, OCI_ASSOC); Header("Content-type: image/".$result[\\'IMGTYPE\\']); echo $result[\\'IMAGE\\']->load(); OCILogoff($conn ); ?> 返回类别: 教程 上一教程: 用php实现gb2312和unicode间的编码转变 下一教程: PHP:路在何方? 您可以阅读与"Oracle中图片的存贮与显示例程"相关的教程: · 用php+oracle实现分页的示例程序 · 我写的一个用PHP+MYSQL轻松实现论坛里的分级+分页显示的例程!(很具体的哦!虽然效率不是最佳,却非... · 用PHP调用数据库的存贮过程 · 在PHP3中实现SESSION的功能(三、示例程序:test_session.php3) · 用PHP调用数据库的存贮过程! |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |