Hi,
 
There is a little mistake in an example script on the http://nl.php.net/manual/nl/function.oci-new-descriptor.php page.
 
The error is in the script where an Oracle BLOB is uploaded into the Oracle database.
 
This is the script I'm talking about:
 
<?php
  
/* This script demonstrates file upload to LOB columns
     * The formfield used for this example looks like this
     * <form action="" method="post" enctype="multipart/form-data">
     * <input type="file" name="lob_upload" />
     * ...
     */
 
if (!isset($lob_upload) || $lob_upload == 'none'){
?>
<form action="" method="post" enctype="multipart/form-data">
Upload file: <input type="file" name="lob_upload" /><br />
<input type="submit" value="Upload" /> - <input type="reset" value="Reset" />
</form>
<?php
 
} else {

    
// $lob_upload contains the temporary filename of the uploaded file

     // see also the features section on file upload,
     // if you would like to use secure uploads
    
    
$conn = oci_connect($user, $password);
    
$lob = oci_new_descriptor($conn, OCI_D_LOB);
    
$stmt = oci_parse($conn, "insert into $table (id, the_blob)
               values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"
);
    
oci_bind_by_name($stmt, ':the_blob', $lob, -1, OCI_B_BLOB);
    
oci_execute($stmt, OCI_DEFAULT);
     if (
$lob->savefile($lob_upload)){
      
oci_execute($conn);
       echo
"Blob successfully uploaded\n";
     }else{
       echo
"Couldn't upload Blob\n";
     }
    
oci_free_descriptor($lob);
    
oci_free_statement($stmt);
    
oci_close($conn);
  }
?>
 
The line oci_execute($conn); should be replaced with oci_commit($conn);.
Greetings,
 
Maurice Lacroix

Reply via email to