Single Article

Simple way to display pictures stored outside Oracle XE in an html region

Category APEX Tricks

Here is how you can show images from server folder: This is just example and assume you create new app. I also assume your XE database is in windows machine. Connect to SQL plus as SYS and create directory:

create directory my_img_dir as 'c:\my_images\';

Grant read privilege on directory to DAD user (ANONYMOUS):

grant read on directory my_img_dir to anonymous;

Grant read privilege on directory to your application parsing schema. Change "my_schema" to your own schema:

grant read on directory my_img_dir to my_schema;

Create new app and 2 blank pages. I assume first page (id 1) is where you show images. Second page (id 2) is just for call application process. Create application process point "On Load:Before Header"

  l_lob     BFILE;
  l_length  NUMBER;
  l_length := DBMS_LOB.getlength(l_lob);
  htp.p('Content-length: ' || l_length);
  htp.p('Content-Disposition: inline; filename="&REQUEST."');
  -- close the headers
  -- download the BLOB

Make process conditional if page is 2. Create HTML region to page 1 and place to region source:

<img src="f?p=&APP_ID.:2:&APP_SESSION.:my_picture.gif" alt="" />

Replace "my_picture.gif" with real image name you have in folder c:\my_images. Image name is case sensitive PS: In above instructions replace c:\my_images\ with e.g. /var/my_images in Linux. Make sure "others" have read permission to folder and image files in it. Folder owner and group can be e.g. root.

Original article in Oracle APEX forum.



  • Jari Laine · 9 Nov 2017  

    Hi Md. Masud Rana,

    I haven't check how use bfile from remote directory.
    Try check Oracle documentation.


  • Md. Masud Rana · 8 Nov 2017  

    Hi Jari

    Very good Post. How can i retrieve image or directory

    which is located shear drive from another pc like

    (create directory drug_image_dir as '\\\smb\image';)

    * When run (user_name/Password) need Application

    how & where i place (user_name/Password) in process?

    ORA-22288: file or LOB operation GETLENGTH failed The specified network password is not correct.

    Thanks a lot



  • Jari Laine · 8 May 2012  
  • jabbar · 8 May 2012  
    Hi, I have some question about your post, 1. i have some files (.jpg,.pdf,.docx) stored in local folder which filename specified in the table. I want to open a file by clicking the record (example filename) of either interactive or classic report in APEX. Can you help with your coding. //l_lob := BFILENAME('IMAGES', :REQUEST); here what it means :REQUEST is a column or what? thanks Abdul Jabbar     
  • Jari Laine · 6 Oct 2011  


    You just output needed HTML before/after image.
    Maybe you PL/SQL dynamic content region.


  • mrosa · 6 Oct 2011  
    Very good article. How can I add some text before/after the picture? I need to build a student cart , with name , period and the photo. thanks.     

Global Right Column



Subscribe in a Reader