分类:
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";
}
?>
//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 );
?>