You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Oracle APEX:如何显示局域网共享文件夹中的图片

Displaying Network Share Images in Oracle APEX

Got it, let's break down how to show those \\SCANS\... images in your Oracle APEX app. I’ve worked through this exact scenario a few times, so here are the two most practical approaches depending on your environment:

Browsers block direct access to \\ network paths for security reasons, so the cleanest fix is to map your shared folder to a web-accessible URL using your APEX web server (like Oracle HTTP Server or Tomcat).

Steps to Configure:

  • Map the Shared Folder as a Virtual Path:
    If you’re using Oracle HTTP Server (OHS), edit your server’s config file (e.g., httpd.conf or a custom .conf file in the conf.d directory) to add an alias pointing to your network share:

    Alias /scans/ "//SCANS/"
    

    Then add directory permissions to allow access:

    <Directory "//SCANS/">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
    

    Pro Tip: Make sure your web server’s service account has read permissions to the \\SCANS share—this is a common gotcha that trips people up!

  • Use the Virtual URL in APEX:
    Now you can reference images directly using the virtual path. For example:

    • In an Interactive Report, set the image column’s source to '/scans/' || your_image_path_column
    • In a Form’s Image component, use a dynamic URL like '/scans/01/01-0001.GIF' (or bind to a page item like '/scans/' || :P1_IMAGE_PATH)

2. PL/SQL Dynamic Content (If Web Server Config Isn’t Possible)

If you can’t modify the web server (e.g., no admin access), you can use PL/SQL to read the image from the network share and stream it directly to the browser.

Prerequisites:

  • Your database server must have access to the \\SCANS share. On Windows, map it to a local drive (e.g., Z:\); on Linux, mount it using cifs-utils.
  • Create a database directory object pointing to the mapped/mounted path:
    CREATE OR REPLACE DIRECTORY SCANS_DIR AS 'Z:\';
    
  • Grant read access to APEX’s runtime user (typically APEX_PUBLIC_USER):
    GRANT READ ON DIRECTORY SCANS_DIR TO APEX_PUBLIC_USER;
    

Implement in APEX:

  1. Create a new blank page (e.g., page 100) dedicated to serving images.
  2. Add a Dynamic Content region to the page, with this PL/SQL code:
    DECLARE
        l_file BFILE;
        l_blob BLOB;
    BEGIN
        -- :P100_IMAGE_PATH is a page item that holds the relative path (e.g., '01/01-0001.GIF')
        l_file := BFILENAME('SCANS_DIR', :P100_IMAGE_PATH);
        DBMS_LOB.OPEN(l_file, DBMS_LOB.LOB_READONLY);
        DBMS_LOB.CREATETEMPORARY(l_blob, TRUE);
        DBMS_LOB.LOADFROMFILE(l_blob, l_file, DBMS_LOB.GETLENGTH(l_file));
        DBMS_LOB.CLOSE(l_file);
    
        -- Set HTTP headers for GIF images
        OWA_UTIL.MIME_HEADER('image/gif', FALSE);
        HTP.P('Content-Length: ' || DBMS_LOB.GETLENGTH(l_blob));
        OWA_UTIL.HTTP_HEADER_CLOSE;
    
        -- Stream the image to the browser
        WPG_DOCLOAD.Download_FILE(l_blob);
        DBMS_LOB.FREETEMPORARY(l_blob);
    END;
    
  3. On your main page, use this URL as the image source:
    f?p=&APP_ID.:100:&SESSION.::NO::P100_IMAGE_PATH:01/01-0001.GIF
    
    Replace 100 with your image-serving page number, and bind P100_IMAGE_PATH to your actual image path value.

Key Notes:

  • Always test permissions first—if the web server or database account can’t access the share, nothing will load.
  • For large image libraries, the web server mapping method is faster and more scalable than streaming via PL/SQL.

内容的提问来源于stack exchange,提问作者shahidyasin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 22:32:30