国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

Oracle中圖片的存貯與顯示例程

2024-08-29 13:32:30
字體:
來源:轉載
供稿:網友
//store.php
<html>
<head><title>store binary data into oracle database</title></head>
<body>

<?php
// 如果提交了表單,代碼將被執行:
dl("php_oci8.dll");
$conn = ocilogon("scott","tiger");
if ($submit) {

echo "file name: <b>$userfile_name</b><br>/n";
echo "file size: <b>$userfile_size</b><br>/n";

$hwsize = getimagesize($userfile );
$w = $hwsize[0];
$h = $hwsize[1];
echo "image width: <b>$w</b><br>/n";
echo "image height: <b>$h</b><br>/n";

$imgtype = strtolower(substr( strrchr( $userfile_name, "." ), 1 ) );
if ($imgtype == "jpg")
  $imgtype = "jpeg";
echo "image type: <b>$imgtype</b><br>/n";

echo "created date; <b>".date('y-m-d')."</b><br>/n";


$sql = "insert into
picture (picid, username, width, height, imgsize, imgtype, created, image, filename, description)
values(picturepicid.nextval, '$username', $w, $h, '$userfile_size', '$imgtype', to_date('".date('y-m-d')."','yyyy-mm-dd'), empty_blob(), '$userfile_name', '$description')
returning image into :image";

echo "<pre>$sql</pre>";
$stmt = ociparse($conn, $sql );

$image = ocinewdescriptor($conn );

ocibindbyname($stmt, ":image", $image, -1, sqlt_blob );

if (!ociexecute($stmt, oci_default)) {
  echo "execution failed";
  exit(1);
}

$fp = fopen($userfile, "r" );
$image->save(fread($fp, filesize($userfile ) ) );
fclose($fp );
ocicommit($conn );

ocifreestatement($stmt );

} else {
?>
    <form method="post" action=" <?php echo $php_self; ?>" enctype="multipart/form-data">
    file description:<br>
    <input type="text" name="description"  size="40">
    <input type="hidden" name="max_file_size" value="1000000">
    <br>file to upload/store in database:<br>
    <input type="file" name="userfile"  size="40">
    <p><input type="submit" name="submit" value="submit">
    </form>

<?php
}
?>
</body>
</html>
//display.php
<?php
/*
  purpose:
    display an image from 'picture' table
*/
dl("php_oci8.dll");
$conn = ocilogon("scott","tiger");
$stmt = ociparse($conn, "select image, imgtype from picture where picid=23" );
ociexecute($stmt);

@ocifetchinto($stmt, &$result, oci_assoc);
header("content-type: image/".$result['imgtype']);
echo $result['image']->load();

ocilogoff($conn );
?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汤阴县| 二连浩特市| 扶风县| 类乌齐县| 都匀市| 阿尔山市| 喀喇| 堆龙德庆县| 会同县| 呼和浩特市| 航空| 都昌县| 潼南县| 吉隆县| 绿春县| 且末县| 沂源县| 黄山市| 郴州市| 南平市| 乡宁县| 鲁甸县| 卢湾区| 定结县| 中西区| 鲁山县| 商丘市| 隆昌县| 静乐县| 怀仁县| 河津市| 榆中县| 团风县| 岳西县| 镇巴县| 禄劝| 浦江县| 崇左市| 嵊州市| 麦盖提县| 汽车|