简体   繁体   English

如何使用 PHP 将 Blob 显示为来自 oracle 的图像

[英]How to display blob as image from oracle using PHP

I'm trying to display an image that is stored as a blob in oracle using PHP.我正在尝试使用 PHP 在 oracle 中显示存储为 blob 的图像。 I'm using the adodb library.我正在使用 adodb 库。

The code is as follows:代码如下:

<?php
$db=conGenedesa();
    $query ="SELECT * FROM 'TABLE' p WHERE p.ID = $id";
    $result = odbc_exec($db, $query);

    $name;
    $dni;
    $jobID;
    $base;
    while(odbc_fetch_row($result)){
        $name = odbc_result($result, 'PER_APELLIDO_PATERNO') . ' ' . odbc_result($result, 'PER_APELLIDO_MATERNO') . ' ' . odbc_result($result, 'PER_NOMBRES');
        $dni = $rut . '-' . odbc_result($result, 'PER_RUT_DV');
        $jobID = odbc_result($result, 'PER_CAR_CODIGO');
        $base = odbc_result($result, 'PER_MOVIL_IMG');
    }

    $src;
    if($base == null){
        echo 'null';
    }
    else{
        $src='data:image/jpeg;base64,'.base64_encode($base);
    }
?>
<img src="<?php echo $src; ?>" />

I know the image is not corrupted, because i can see it from another application using dotnet.我知道图像没有损坏,因为我可以从另一个使用 dotnet 的应用程序中看到它。

UPDATE:更新:

In the end, PHP was truncating the blobs output.最后,PHP 截断了 Blob output。 I corrected it inserting this line.我纠正了它插入这一行。

ini_set('odbc.defaultlrl', '10M');

Although it's for OCI8 not ADOdb, the section "Uploading and Displaying an Image" on page 236 of The Underground PHP and Oracle Manual may have some helpful clues.虽然它适用于 OCI8 而不是 ADOdb,但The Underground PHP 和 Oracle 手册第 236 页上的“上传和显示图像”部分可能有一些有用的线索。

Since you seem to have fetched your data OK, your question isn't really an Oracle one, so plenty of other resource can be used.由于您似乎已经正确获取了数据,因此您的问题并不是真正的 Oracle 问题,因此可以使用大量其他资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM