note 14357 added to function.ocinewdescriptor.php
| From: | stevehalasz at yahoo dot com | Date: | Fri, 27 Jul 2001 15:25:31 +0000 |
| Subject: | note 14357 added to function.ocinewdescriptor.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15943@lists.php.net to get a copy of this message | ||
The upload example does not seem to work for images, at least on Win32 where binary files are
treated differently. The following does work:
// $lob_upload contains the temporary filename of the uploaded file
$image = fread(fopen($lob_upload, "rb"), filesize($lob_upload));
$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, OCI_DEFAULT);
if($lob->save($image)){
OCICommit($conn);
echo "Blob successfully uploaded\n";
}else{
echo "Couldn't upload Blob\n";
}
OCIFreeDesc($lob);
OCIFreeStatement($stmt);
OCILogoff($conn);
http://www.php.net/manual/en/function.ocinewdescriptor.php