Please note, that contents of LOB is cleared after this operation. If you want to use LOB data after exporting it to file, you should read it from file with file_get_contents().
This will not work:
<?php
if($blob) {
$filename = DOCUMENT_ROOT."/".$bildId.".jpg";
if($blob->export($filename)) {
while(!$blob->eof()){
$dbResult .= $blob->read(2000);
}
} else {
throw new Exception("Can not save the file ".$filename."!");
}
}
?>
Use this instead:
<?php
if($blob) {
$filename = DOCUMENT_ROOT."/".$bildId.".jpg";
if($blob->export($filename)) {
$dbResult = file_get_contents($filename);
} else {
throw new Exception("Can not save the file ".$filename."!");
}
}
?>
OCI-Lob::export
(PHP 5, PECL OCI8 >= 1.1.0)
OCI-Lob::export — Exports LOB's contents to a file
Description
bool OCI-Lob::export
( string
$filename
[, int $start
[, int $length
]] )Exports LOB contents to a file.
Parameters
-
filename -
Path to the file.
-
start -
Indicates from where to start exporting.
-
length -
Indicates the length of data to be exported.
Return Values
Returns TRUE on success or FALSE on failure.
AlexiuS ¶
1 month ago
