views:

169

answers:

2

Hi,

I'm using a php script to save a binary stored in the server's temp directory into oracle as a blob. It works fine for filesizes < 7MB, any larger than that and it just doesn't save. The php post and file upload limit is 32MB. The script stops completely at lob->savefile($tempFile). The general code is below:

$stid = oci_parse($conn, "UPDATE FILE_UPLOAD SET file_blob = EMPTY_BLOB(), status = 'S', temp_file = '{$tempFile}' WHERE FILE_UPLOAD_ID = :file_id RETURNING file_blob INTO :file_blob"); oci_bind_by_name($stid, ':file_blob', $lob, -1, OCI_B_BLOB);
oci_bind_by_name($stid, ':file_id', $fileID);
oci_execute($stid, OCI_DEFAULT);

if ($lob->savefile($tempFile)) // this is where it stops
{
oci_commit($conn);
}
else
{
logAction("Status", "Couldn't upload Blob"); // doesn't get here
}

Any advice would be appreciated.

Regards,

Angus

+1  A: 

You can enable tracing for your session and see the trace file. Perhaps it will contain error which is cause of the problem.

EXECUTE DBMS_SESSION.SESSION_TRACE_ENABLE(waits => TRUE, binds => FALSE);

The following script returns the path to the trace file that the current session writes. It returns the path whether or not tracing is enabled.

select 
  u_dump.value   || '/'     || 
  db_name.value  || '_ora_' || 
  v$process.spid || 
  nvl2(v$process.traceid,  '_' || v$process.traceid, null ) 
  || '.trc'  "Trace File"
from 
             v$parameter u_dump 
  cross join v$parameter db_name
  cross join v$process 
        join v$session 
          on v$process.addr = v$session.paddr
where 
 u_dump.name   = 'user_dump_dest' and 
 db_name.name  = 'db_name'        and
 v$session.audsid=sys_context('userenv','sessionid');
dba.in.ua
A: 

Well the problem has been resolved after much debugging, etc. The answer lays herein:

where I was accessing the tempfile directly, i.e. $tempFileN= $_FILES['Filedata']['tmp_name'] and saving that, I replaced it with:
$contents = file_get_contents($_FILES['Filedata']['tmp_name']);

and where I was saving the blob using the savefile method, I changed it to:
$lob->save($contents)

It works now.

Angus