From c4080e1f34b0e7c69d6fdb5b19154e089d6a0bba Mon Sep 17 00:00:00 2001 From: Andreas Karajannis Date: Tue, 31 Aug 1999 08:32:19 +0000 Subject: [PATCH] Corrections to OCINewDescriptor git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@12346 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/oci8.sgml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/functions/oci8.sgml b/functions/oci8.sgml index 8389279bc5..25248664a9 100644 --- a/functions/oci8.sgml +++ b/functions/oci8.sgml @@ -532,6 +532,8 @@ print "</PRE></HTML>"; OCINewDescriptor Allocates storage to hold descriptors or LOB locators. Valid values for the valid type are OCI_D_FILE, OCI_D_LOB, OCI_D_ROWID. + For LOB desriptors, the methods load, save, and savefile are associated with the descriptor, + for BFILE only the load method exists. See the second example usage hints. @@ -564,6 +566,39 @@ print "</PRE></HTML>"; OCIFreeStatement($stmt); OCILogoff($conn); ?> + +<?php + /* This script demonstrates file upload to LOB columns + * The formfield used for this example looks like this + * <form action="upload.php3" method="post" enctype="multipart/form-data"> + * <input type="file" name="lob_upload"> + * ... + */ + if(!isset($lob_upload) || $lob_upload == 'none'){ +?> +<form action="upload.php3" method="post" enctype="multipart/form-data"> +Upload file: <input type="file" name="lob_upload"><br> +<input type="submit" value="Upload"> - <input type="reset"> +</form> +<?php + } else { + // $lob_upload contains the temporary filename of the uploaded file + $conn = OCILogon($user, $password); + $lob = OCINewDescriptor($conn, OCI_D_LOB); + $stmt = OCIParse($conn,"insert into $table (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"); + OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB); + OCIExecute($stmt); + if($lob->savefile($lob_upload)){ + OCICommit($conn); + echo "Blob successfully uploaded\n"; + }else{ + echo "Couldn't upload Blob\n"; + } + OCIFreeDescriptor($lob); + OCIFreeStatement($stmt); + OCILogoff($conn); + } +?>