您的位置:首页 > 数据库 > Oracle

【转】php 存储文件到oracle blob 字段

2009-12-07 14:25 459 查看
<?php
$lob_upload = $_FILES['lob_upload'];
if (!isset($lob_upload) || $lob_upload == 'none'){
?>
<?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/finaltest";
$db_user   = "root";
$db_pass   = "localhost!@#";
$conn = oci_connect($db_user, $db_pass,$db_host);
$lob = oci_new_descriptor($conn, OCI_D_LOB);
$table = 'dutbin';
$stmt = oci_parse($conn, "INSERT INTO dutbin (CustomerLotID ,State ,Hifix ,Pgm ,/"Pgm version/" ,Device ,Tester ,/"Date/" ,StartTime ,Bin) VALUES ('$customerid', '$state', '$hifix', '$pgm', '$pgm_version', '$device', '$tester', '$date', '$time', EMPTY_BLOB()) returning Bin into :the_blob");
oci_bind_by_name($stmt, ':Bin, $lob, -1, OCI_B_BLOB);
oci_execute($stmt, OCI_DEFAULT);
if ($lob->saveFile($lob_upload['tmp_name'])){
oci_commit($conn);
echo "Blob successfully saved/n";
}else{
echo "Couldn't saved Blob/n";
}
oci_free_descriptor($lob);
oci_free_statement($stmt);
oci_close($conn);
}
?>


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hxw001/archive/2009/05/22/4208747.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: