<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?php
if($_FILES["filUpload"]["name"] != "")
{
//*** Insert Record ***//
$objConnect = oci_connect("myuser","mypassword","TCDB");
$lob = oci_new_descriptor($objConnect, OCI_D_LOB);
$strSQL = "INSERT INTO FILES ";
$strSQL .="(FILESID,NAME,FILESTYPE,FILESNAME) VALUES ";
$strSQL .="(seq_next_filesid.nextval,'".$_POST["txtName"]."' ";
$strSQL .=",'".$_FILES["filUpload"]["type"]."',EMPTY_BLOB()) RETURNING FILESNAME INTO :BLOBDATA";
$objParse = oci_parse($objConnect, $strSQL);
oci_bind_by_name($objParse, ':BLOBDATA', $lob, -1, OCI_B_BLOB);
$objExecute = oci_execute($objParse, OCI_DEFAULT);
$lob->savefile($_FILES['filUpload']['tmp_name']);
if($objExecute)
{
oci_commit($objConnect);
echo "Copy/Upload Complete<br>";
}
else
{
oci_rollback($objConnect);
echo "Copy/Upload is not Complete";
}
oci_free_descriptor($lob);
oci_free_statement($objParse);
oci_close($objConnect);
}
?>
<a href="PageUploadToOracle3.php">View files</a>
</body>
</html>