File Description: File to upload/store in database:"> File Description: File to upload/store in database:" />
科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道Oracle中图片的存贮与显示例程

Oracle中图片的存贮与显示例程

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

" method=post encType=multipart/form-data> File Description: File to upload/store in database:

作者:中国IT实验室 来源:中国IT实验室 2007年10月6日

关键字: 甲骨文 开发 数据库 ORACLE




// 如果提交了表单,代码将被执行:
dl("php_oci8.dll");
$conn = OCILogon("scott","tiger");
if ($submit) {
echo "File name: $userfile_name
";
echo "File size: $userfile_size
";
$hwsize = GetImageSize($userfile );
$w = $hwsize[0];
$h = $hwsize[1];
echo "Image width: $w
";
echo "Image height: $h
";
$ImgType = strtolower(substr( strrchr( $userfile_name, "." ), 1 ) );
if ($ImgType == "jpg")
  $ImgType = "jpeg";
echo "Image type: $ImgType
";
echo "Created date; ".date("Y-m-d")."
";
$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 "

$sql
";
$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 {
?>
   

    File Description:

   
   
   
File to upload/store in database:

   
   


   

 

}
?>


//display.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 );
?> 

查看本文来源

    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章