Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to load folder with images php with oracle

997232May 2 2013 — edited May 3 2013
Hi i want to upload from my php form folder with images what should i fix in my php code for 1 image?

<?php

define("ORA_CON_UN", "obrazy");
define("ORA_CON_PW", "miksas1");
define("ORA_CON_DB", "//localhost/orcl");

if (!isset($_FILES['lob_upload'])) {
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
enctype="multipart/form-data">
Image filename: <input type="file" name="lob_upload">
<input type="submit" value="Upload">
</form>

<?php
}
else {

$conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);


// Insert the BLOB from PHP's tempory upload area

$lob = oci_new_descriptor($conn, OCI_D_LOB);
$stmt = oci_parse($conn, 'INSERT INTO FOTKI (FOTKAID, FOTKA) '
.'VALUES(:MYBLOBID, EMPTY_BLOB()) RETURNING FOTKA INTO :FOTKA');
oci_bind_by_name($stmt, ':MYBLOBID', $myblobid);
oci_bind_by_name($stmt, ':FOTKA', $lob, -1, OCI_B_BLOB);
oci_execute($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'])) {
oci_commit($conn);
echo '<p>Obrazek załadowano</p>';
}
else {
echo "Couldn't upload Blob\n";
}
$lob->free();
oci_free_statement($stmt);

oci_close($conn); // log off
}

?>

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 31 2013
Added on May 2 2013
1 comment
1,890 views