来源: php 存储文件到oracle blob 字段_xiangmingliang123_新浪博客
<?php
$lob_upload = $_FILES[‘lob_upload’];
if (!isset($lob_upload) || $lob_upload == ‘none’){
?>
<form method=”post” enctype=”multipart/form-data”>
Upload file: <input type=”file” name=”lob_upload” /><br />
<input type=”submit” value=”Upload” /> – <input type=”reset” value=”Reset” />
</form>
<?php
} else {
// $lob_upload contains the temporary filename of the uploaded file
// see also the features section on file upload,
// if you would like to use secure uploads
ini_set(‘display_errors’,1);
$db_host = “//192.168.1.9/JSHDB”;
$db_user = “lterp”;
$db_pass = “juyitong2009”;
$conn = oci_connect($db_user, $db_pass,$db_host);
$lob = oci_new_descriptor($conn, OCI_D_LOB);
$table = ‘PICTURES’;
$stmt = oci_parse($conn, “insert into $table (id, the_blob)
values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob”);
oci_bind_by_name($stmt, ‘:the_blob’, $lob, -1, OCI_B_BLOB);
oci_execute($stmt, OCI_DEFAULT);
if ($lob->saveFile($lob_upload[‘tmp_name’])){
oci_commit($conn);
echo “Blob successfully uploaded/n”;
}else{
echo “Couldn’t upload Blob/n”;
}
oci_free_descriptor($lob);
oci_free_statement($stmt);
oci_close($conn);
}
?>