Hello.
I must put a pdf Dokument from Server into Oracle DB
I have found a Dokumentationscript on www.oracle.com.
<?php
//
// Sample form to upload and insert data into an ORACLE CLOB column
// using PHP's Oracle 8 API.
//
// Based on http://www.php.net/manual/en/function.oci-new-descriptor.php
// modified to work on CLOBs and use register_globals = Off.
//
// Before running this script, execute these statements in SQL*Plus:
// drop table myclobtab;
// create table myclobtab (c1 number, c2 clob);
//
// Tested with PHP 4.3.3 against Oracle 9.2
//
if (!isset($_FILES['lob_upload'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
Upload file: <input type="file" name="lob_upload">
<input type="submit" value="Upload">
</form>
<?php
}
else {
$myid = 1; // should really be a unique id e.g. a sequence number
$conn = OCILogon('secret', 'secret', 'secret');
// Delete any existing CLOB so the query at the bottom
// displays the new data
#$query = 'DELETE FROM MYCLOBTAB';
#$stmt = OCIParse ($conn, $query);
#OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);
#OCIFreeStatement($stmt);
// Insert the CLOB from PHP's temporary upload area
$lob = OCINewDescriptor($conn, OCI_D_LOB);
$stmt = OCIParse($conn, "INSERT INTO \"tblArchiv\" (\"AR_Objekt\") VALUES(EMPTY_BLOB()) RETURNING \"AR_Objekt\" INTO :C2");
OCIBindByName($stmt, ':C2', $lob, -1, OCI_B_BLOB);
OCIExecute($stmt, OCI_DEFAULT);
// The function $lob->savefile(...) reads from the uploaded file.
// If the data was already in a PHP variable $myv, the
// $lob->save($myv) function could be used instead.
if ($lob->savefile($_FILES['lob_upload']['tmp_name'])) {
OCICommit($conn);
echo "CLOB successfully uploaded\n";
}
else {
echo "Could not upload CLOB\n";
}
$lob->free();
OCIFreeStatement($stmt);
OCILogoff($conn);
}
?>
This code runs good.
But my file is on the server. So i have change the code
This line
if ($lob->savefile($_FILES['lob_upload']['tmp_name'])) {
in this line
if ($lob->savefile("a.pdf")) {
the code with Fileupload have i delete.
Now the Code generates a new DB Entry but in the Blob field is nothing.
Please help.
Sorry my english is very bad.
Greets.
Werner