How to insert and show blob images in form and report of Oracle Apex
---------------------Source Code-------------------------
CREATE TABLE emp_test (
emp_id number generated always as identity(start with 1 order),
emp_name varchar2(100),
emp_photo blob,
photo_file_name varchar2(100),
photo_mime_type varchar2(100),
photo_last_update timestamp,
constraint emp_test_pk primary key (emp_id)
);
-------------------show image-------------------
<div class="img-box">
<img src="" alt="Photo" id="preview_img_id" />
</div>
-------------------css code---------------------
.img-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.img-box img {
width: 120px;
max-height: 130px;
min-height: 100px;
border: 1px solid #ddd;
padding: 5px;
}
--------------------Report----------------------
select
decode(nvl(dbms_lob.getlength(EMP_PHOTO),0), 0, null,
'<img src="'||apex_util.get_blob_file_src('P15_EMP_PHOTO', EMP_ID)||'" id="emp_img_id" />') photo
from EMP_TEST
where EMP_ID = :P15_EMP_ID
Comments
Post a Comment