PHP 4.0 Bug #5839: error on using $lob->savefile($form_data) for storing lob into oracle8 db
| From: | rddc at uninova dot pt | Date: | Fri, 28 Jul 2000 15:35:19 +0000 |
| Subject: | PHP 4.0 Bug #5839: error on using $lob->savefile($form_data) for storing lob into oracle8 db | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-26725@lists.php.net to get a copy of this message | ||
From: rddc@uninova.pt
Operating system: Windows 98
PHP version: 4.0.0
PHP Bug Type: Misbehaving function
Bug description: error on using $lob->savefile($form_data) for storing lob into oracle8 db
Instead of using $lob->savefile($form_data) for storing lob into oracle8 db, like is described in
the php manual seccion oracle8 functions.
Use $lob->save(readf($form_data)) becaus function savefile doesn't store the whole lob in
the orcale8 db just a part of it.
Here´s a short script for storing lob into oracle8 db
$sql = "insert into fotos (id, dados, largura, altura, formato,tamanho)";
$sql .= " values ($id, EMPTY_BLOB(), $largura, $altura, '$formato',
$form_data_size)";
$stmt = OCIParse($conn,"$sql returning dados into :lob");
$lob = OCINewDescriptor($conn,OCI_D_LOB);
OCIBindByName($stmt,":lob",$lob,-1,OCI_B_BLOB);
OCIExecute($stmt,OCI_DEFAULT);
if($lob->save(readf($form_data))){
OCICommit($conn);
echo "Blob successfully uploaded\n";
} else {
echo "Couldn't upload Blob\n";
}
Where readf is a function for reading binary data
function readf($filename)
{$fp = fopen($filename,"rb");
$buffer = fread($fp,filesize($filename));
fclose($fp);
return $buffer;
}
Another thing try to look at the function writetofile and fwrite a see the difrences when saving a
lob into a file.
When using writetofile the carriage return (0A) is converted to (0D 0A) under win98.