[SOLVED]OCI_lob::savefile() fails - no error code
Posted: Wed Jul 13, 2011 4:25 pm
I've tried this two separate ways:
AND
Neither is saving my Word document in my BLOB field in the database. The second format (officially an alias of the first format) did save a plain text file in the BLOB field, but every time I try to do this with my Word doc, it throws back a false result.
According to the official, online docs the results are
Anybody seen this before? Any ideas as to WHY it would be failing?
Full code of function:
Thanks in advance for any assistance you can offer.

Code: Select all
if ($lob->import($_FILES['lob_upload']['tmp_name'])) {
Code: Select all
if ($lob->savefile($_FILES['lob_upload']['tmp_name'])) {
According to the official, online docs the results are
So, NO explanation as to WHY it failed, just that it failed.Returns TRUE on success or FALSE on failure.
Anybody seen this before? Any ideas as to WHY it would be failing?
Full code of function:
Code: Select all
public function loadBLOBFile($filePurpose, $fileType, $fileName){
if(!isset($_SESSION['user'])) $_SESSION['user']=1;
$sequence = "blobs_seq";
$myblobid = $this->getNextId($sequence);
$conn = $this->getConnection();
// Delete any existing BLOB
$query = 'DELETE FROM blobTbl WHERE FILEPURPOSE = :FILEPURPOSE '.
'AND USERID = :USERID';
$stid = oci_parse ($conn, $query);
if(!$stid){
$err = oci_error($stid);
$this->setOciErrorMsg($err);
return;
}
oci_bind_by_name($stid, ':FILEPURPOSE', $filePurpose);
oci_bind_by_name($stid, ':USERID', $_SESSION['user']);
$e = oci_execute($stid, OCI_COMMIT_ON_SUCCESS);
if(!$e){
$err = oci_error($e);
$this->setOciErrorMsg($err);
return;
}
oci_free_statement($stid);
// Insert the BLOB from PHP's temporary upload area
$lob = oci_new_descriptor($conn, OCI_DTYPE_LOB);
$stid = oci_parse($conn, 'INSERT INTO blobTbl (BLOBID, FILETYPE, '.
'USERID, FILEPURPOSE, FILENAME, FILEDATA) VALUES (:MYBLOBID, '.
':FILETYPE, :USERID, :FILEPURPOSE, :FILENAME, EMPTY_BLOB()) '.
'RETURNING FILEDATA INTO :BLOBDATA');
if(!$stid){
$err = oci_error($stid);
$this->setOciErrorMsg($err);
return;
}
oci_bind_by_name($stid, ':MYBLOBID', $myblobid);
oci_bind_by_name($stid, ':FILEPURPOSE', $filePurpose);
oci_bind_by_name($stid, ':FILETYPE', $fileType);
oci_bind_by_name($stid, ':USERID', $_SESSION['user']);
oci_bind_by_name($stid, ':FILENAME', $fileName);
oci_bind_by_name($stid, ':BLOBDATA', $lob, -1, OCI_B_BLOB);
$success = oci_execute($stid, OCI_DEFAULT);
if(!$success){
$err = oci_error($stid);
$this->setOciErrorMsg($err);
}
// The function $lob->import(...) reads from the uploaded file.
if ($lob->import($_FILES['lob_upload']['tmp_name'])) {
oci_commit($conn);
$msg = "File upload was successful.\n";
}else{
$msg = "Couldn't upload file.\n";
}
$lob->free();
oci_free_statement($stid);
return $msg;
}