Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2118701
  • 博文数量: 1647
  • 博客积分: 80000
  • 博客等级: 元帅
  • 技术积分: 9980
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 15:15
文章分类

全部博文(1647)

文章存档

2011年(1)

2008年(1646)

我的朋友

分类:

2008-10-28 17:59:09




// 如果提交了表单,代码将被执行:
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 );
?> 

【责编:landss】

--------------------next---------------------

阅读(104) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~