Download_my_file procedure

I want to restrict the download to a username that matches the login user (HTMLDB)
In the table file_subjects table I have column 'owner'.
How do I get the HTMLDB user from the procedure download_my_file?
Tried:
HTMLDB_APPLICATION.G_USER;
HTMLDB_CUSTOM_AUTH.GET_USERNAME;
owa_util.get_cgi_env('REMOTE_USER');
Thanks

ok - i did it the easy way using the cookie name.
v_cookie2 owa_cookie.cookie;
v_cookie3 varchar2(80); -- User Name in the cookie
v_cookie2 := owa_cookie.get('LOGIN_USERNAME_COOKIE');
if v_cookie2.num_vals != 0 then
v_cookie3 := v_cookie2.vals(1);
end if;
if v_doc_type <> 'PUBLIC' and upper(v_cookie3) <> v_owner
then
htp.p('<html>');
htp.p('<head>');
htp.p('<meta http-equiv="Content-Type" content="text/html">');
htp.p('<title>Unauthorized file download access</title>');
htp.p('</head>');
htp.p('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
htp.p('<h1>Unauthorized access</h1>');
htp.p('</body>');
htp.p('</html>');
htp.p('Your IP address is '||owa_util.get_cgi_env('REMOTE_ADDR'));
htp.nl;
htp.p('You are logged in as: '||v_cookie3);
htp.nl;
htp.nl;
htp.nl;
htp.p('Unauthorized access - file will not be retrieved');
-- htp.anchor('f?p=106:3:'||v('SESSION'),v('SESSION');
htp.nl;
htp.nl;
htp.p('Return to application');
return;
else
Thanks for your input

Similar Messages

  • Error in download_my_file procedure

    Every time I run the script used for allowing the download of uploaded files on a custom table, I get the following error:
    ERROR at line 22: PLS-00103: Encountered the symbol "AS" when expecting one of the following: := . ( @ % ; The symbol ":= was inserted before "AS" to continue.
    The script that I run is:
    CREATE OR REPLACE procedure download_my_file(p_file in number) as
         v_mime varchar2(255);
         v_length number;
         v_file_name varchar2(2000);
         Lob_loc BLOB;
    BEGIN
         select mime_type, blob_content, name,dbms_lob.getlength(blob_content)
              into v_mime,lob_loc,v_file_name,v_length
              from file_subjects
              where id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="' || v_file_name || '"');
              -- close the headers          
    owa_util.http_header_close;
              -- download the BLOB
              wpg_docload.download_file( Lob_loc );
    end download_my_file;
    I have no idea why it is returning the error. Any help would be appreciated :)

    I don't see anything distinctly wrong.
    Here is my download_my_file procedure that I use. It's highly modified to fit my needs but maybe it'll help you.
    CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) as
         v_mime varchar2(255);
         v_length number;
         v_file_name varchar2(2000);
         Lob_loc BLOB;
    BEGIN
         select image, substr(name, instr(name, '/') +1) ,dbms_lob.getlength(image)
              into lob_loc,v_file_name,v_length
              from stationery_images_tbl
              where id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( 'IMAGE/JPG', FALSE );
    -- owa_util.mime_header( 'IMAGE/GIF', FALSE );
    htp.p('Content-length: ' || v_length);
    htp.p('Content-Disposition: filename="' || v_file_name || '"');
              -- close the headers
    owa_util.http_header_close;
              -- download the BLOB
              wpg_docload.download_file( Lob_loc );
    end download_my_file;
    Hope this helps.
    James

  • PROCEDURE download_my_file(added a INSERT statement)

    I have added the INSERT statement with th the Downlad File procedure to track the users, who downloaded the document. Some how, user_id value is inserting as hyphen '-' instaed of login user_id and other values id and sysydate are OK. I have tried v('app_user') in INSERT statement also and it didn't helped.
    Appreciate your help.
    create or replace PROCEDURE download_my_file(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    login_user varchar2(40);
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM DOCTRACKER_BASE
    WHERE id = p_file;
    select v('APP_USER')into login_user from dual;
    insert into schemax.tablea values
    (p_file, login_user, SYSDATE);
    -- insert into schemax.tablea values
    -- (p_file, v('app_user'), SYSDATE);
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    wpg_docload.download_file( Lob_loc );
    end download_my_file;

    Thanks for your reply. I have a simple quetion on how to pass more than one variable to procedure.
    Currently , I am passing only one parameter to DOWNLOAD_MY_FILE procedure from APEX page as below.
    #OWNER#.download_my_file?p_file=#DOCUMENT_ID#
    I have created page item and populated with USER_ID and how to pass this variable as an additional parameter to DOWNLOAD_MY_FILE procedure?
    Appreciate your help..
    Thanks,

  • Download_my_file example from HTMLDB 2 day developer Guide

    Hi -
    I'm using htmldb/APEX v 1.6. I'm following the Oracle HTMLDB 2 Day Developer Guide chapter 8. In this example, we are uploading files to be stored in the database as BLOB's. Then we are downloading the files.
    The example works as advertised until we create the custom table and procedure called download_my_file.
    Using the default table and procedure, the file upload and download work correctly.
    Using the procedure called download_my_file fails with error:
    [Thu Feb  4 13:11:18 2010] [error] [client 100.100.100.11] [ecid: 1265307078:100.100.100.202:18991:0:163,0] mod_plsql: /pls/htmldb/HTMLDB.DOWNLOAD_MY_FILES HTTP-404 \nHTMLDB.DOWNLOAD_MY_FILES: PROCEDURE DOESN'T EXIST\n
    Here is my version of procedure download_my_file:
    (p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM file_subjects_1
    WHERE id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'),FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    end download_my_file;
    Edited by: user11367243 on Feb 4, 2010 11:27 AM
    Execute privileges on procedure download_my_file have been granted to Public and HTMLDB_PUBLIC_USER. Procedure is owned by user HTMLDB

    Please.. Could you change your forum handle to something more human, we are a friendly group here and lik to know who we are talking to.. Secondly, WHy are you using such an OLD version oft he product. You would be better off installing 3.2.1 (latest released build) and asking your questions after you do that..
    (I am sorry, it's like asking for help in a Windows support forum about issues you are having with Windows 3.1)
    Thank you,
    Tony Miller
    Webster, TX

  • Download_my_file open file inside browser without dialog

    how do i amend the download_my_file procedure so that it will open a pdf, word etc file inside the browser automatically. i want it to behave just as any site does when i click a pdf, it doesnt ask me to save or open it, it just opens it inside my browser.
    here is my code
    -- set up HTTP header
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="' || v_file_name || '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    anybodys help would be greatly appreciated

    PROCEDURE SHOW_LOB (
                p_id          IN XE_LOBS.ID%TYPE
              , p_show_inline IN PLS_INTEGER DEFAULT 0
      IS
        l_mime_type    XE_LOBS.MIME_TYPE%TYPE ;
        l_file_name    XE_LOBS.FILE_NAME%TYPE;
        l_display_name XE_LOBS.DISPLAY_NAME%TYPE;
        l_lob_size     XE_LOBS.LOB_SIZE%TYPE;
        l_lob_value    BLOB;
        l_user_id      HTMLDB_USERS.USERNAME%TYPE DEFAULT -1;
        l_illegal_msg  Tool.long_msg_t%TYPE;
      BEGIN
        BEGIN
          SELECT mime_type  , file_name  , display_name  , lob_size  , lob_value
            INTO l_mime_type, l_file_name, l_display_name, l_lob_size, l_lob_value
            FROM XE_LOBS
           WHERE ID = p_id;
        EXCEPTION
          WHEN NO_DATA_FOUND THEN
            Pkg_Pragma_Core.auto_log_error('fnc "SHOW_LOB"!');
            RAISE Tool.MY_FORCED_EXCEPTION;
          WHEN OTHERS THEN
            Pkg_Pragma_Core.auto_log_error('fnc "SHOW_LOB"-2. when others)!');
            RAISE Tool.MY_FORCED_EXCEPTION;
        END;
        -- Set Up Http Header
        -- Use An Nvl Around The Mime Type And  If It Is A Null, Set It To
        -- Application/octect - Which May Launch A Download Window From Windows
        Owa_Util.MIME_HEADER(NVL(l_mime_type,'application/octet'), FALSE );
        -- Set The Size So The Browser Knows How Much To Download
        Htp.P('Content-length: ' || l_lob_size);
        IF p_show_inline=1 THEN
          Htp.P('Content-Disposition:  filename="'||l_file_name||'"');
        ELSE
             -- the filename will be used by the browser if the users does a save as ... extension work
          Htp.P('Content-Disposition:  attachment; filename="'||l_file_name||'"');
        END IF;
        -- Close The Headers
        Owa_Util.Http_Header_Close;
        -- Download The Blob
        Wpg_Docload.Download_File( l_lob_value );
      EXCEPTION
        WHEN Tool.MY_FORCED_EXCEPTION THEN
          htp.P(Tool.XE_LANG_MESSAGE(Tool.others_error_msg_user,Tool.others_error_msg_user_en)||' Back');
        WHEN OTHERS THEN
          Pkg_Pragma_Core.auto_log_error('fnc "SHOW_LOB"-when others error (glavni)!');
          htp.P(Tool.XE_LANG_MESSAGE(Tool.others_error_msg_user,Tool.others_error_msg_user_en)||' Back');
      END SHOW_LOB;If "p_show_inline" is 0 then save as dialog is shown, else if p_show_inline=1 then inline presentation of lob (in browser-that is what you want!)
    XE_LOBS is table where lobs are saved:
    XE> desc xe_lobs
    Name                                                  Null?    Type
    ID                                                    NOT NULL NUMBER(38)
    STATUS                                                NOT NULL NUMBER(38)
    MIME_TYPE                                                      VARCHAR2(128 CHAR)
    FILE_NAME                                                      VARCHAR2(255 CHAR)
    LOB_VALUE                                                      BLOB
    LOB_SIZE                                                       NUMBER(38)

  • Set filename = wwv_flow_file_mgr.get_file

    Hi all,
    I would like to upload a unique file from Shared components > Static Files[br]
    So i use the following syntax :
    [a href='#WORKSPACE_IMAGES#file.txt']file.txt[a]
    The package wwv_flow_file_mgr calls the procedure get_file via :
    wwv_flow_file_mgr.get_file?p_security_group_id=#NUMBER#&p_fname=file.txt
    When i download the file, the confirmation window proposes the default filename as 'wwv_flow_file_mgr.get_file' but not 'file.txt'
    Can anyone explain me why?
    Is there a workaround to solve it?
    Regards,
    Grégory
    Message was edited by:
    mercierg
    Message was edited by:
    mercierg
    Message was edited by:
    mercierg

    Hi,
    I've noticed that as well.
    The only thing I could suggest would be to create your own download procedure. Follow the advice in for downloading files:
    http://download-uk.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm#CJAHDJDA
    Look for the download_my_file procedure. Edit this to get the files from APEX_APPLICATION_FILES instead of a custom table. You also need to ensure that you also grant rights to the procedure:
    GRANT EXECUTE ON download_my_file TO PUBLIC
    Regards
    Andy

  • Displaying images stored in blob columns

    I've seen discussions on how to upload and download blob columns but I want to store a blob in the database and be able to display the blob (which is a jpg) as I would any other <img> on my web page. Instead of having to store the jpg on a file system somewhere, and use the data in the database to formulate a link to the image on the file share, I want to pull it right out of the blob. Does someone have a sample of how to do this? Can I do this?
    Thanks

    Laurence,
    If you uploaded the image via the Application Builder, you can use an image tag like so:
    &lt;img src="#WORKSPACE_IMAGES#my_image.jpg" /&gt;If you followed the upload/download how to, you should be able to reference an image like this:
    &lt;img src="download_my_file?p_file=1232897645" /&gt;Where 1232897645 is the unique ID of the uploaded image. To make referencing images easier, you could write a version of the download_my_file procedure that takes in the name of the image as a parameter.
    Sergio

  • Unable to create Policy Definitions in CM 4.1.1c

    I'm trying to create a Policy Definition and assign it to an Application I created, but I when I click Submit an error pops up stating:
    Transaction not completed. Policy entry cannot be updated as there is no policy entry of type Other. Please create a policy of type Other or update the type of this policy to Other.
    I want this Policy to be type Basic, not Other, and there is a type Other - which I'm not choosing. So why is this error popping up? I first tried this using version 4.1.1d, but it failed so I downgraded to 4.1.1c and it still fails.
    I've attached a Word document with a few screen shots showing the error, and the fact that there is a type Other, even though I don't want to use it.
    Am I doing this wrong or have I stumbled on a bug?

    Hello,
    Read "Create Download Page for Embedded PL/SQL Gateway" section in following documentation.
    http://docs.oracle.com/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CIHDDJGF
    <li> The first option is to modify the PL/SQL function WWV_FLOW_EPG_INCLUDE_MOD_LOCAL to include the PL/SQL download_my_file procedure and then recompile
    <li> The second, described below, is to create a page in the application that has a before header branch to the PL/SQL download_my_file procedure. You then create a hidden item on that page for the document ID of the document to be downloaded.
    I like and have used second option because, you can re-use apex specific features like Authorization schemes etc.
    Please note that if you want to invoke custom procedures via URL, then you should allow them at web-server level. Above documentation explains this for EPG.
    Regards,
    Hari

  • Download file in mobile application

    Hi:
    It's understood that setting up a download link from a custom table is accomplished via the following -
    [from http://docs.oracle.com/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CIHBFCDH ]
    Create Download Page for Embedded PL/SQL Gateway
    The Oracle XML DB HTTP Server with the embedded PL/SQL Gateway is typically used for Application Express in Oracle Database 11g. Calling a PL/SQL procedure directly from a URL that is not known in a list of allowed procedures, as shown in Change the Download Link to Use the New Procedure, results in an error message.
    To avoid this situation, there are a couple of available options. The first option is to modify the PL/SQL function WWV_FLOW_EPG_INCLUDE_MOD_LOCAL to include the PL/SQL download_my_file procedure and then recompile. The second, described below, is to create a page in the application that has a before header branch to the PL/SQL download_my_file procedure. You then create a hidden item on that page for the document ID of the document to be downloaded.
    I have been using the great new tools in 4.2 to create mobile applications with much success on a 4.2.0.00.27 platform. However, when I set up a download page as prescribed, the result on my Samsung Galaxy S3 is not user-friendly on either Firefox or the Google browser. When the user clicks on a download link, the result is a blank page with the word "undefined". If the user reloads the page, then a message appears briefly "Starting download..." If the user then opens the "pull down menu" the download appears in the Notifications section. So it works, but it's not intuitive or even easy to figure out what happened.
    Does anyone have any knowledge of this? Is there some way to control the message on the "undefined" page? Is there a way to cause the smartphone to automatically open the file?
    Thanks all!
    Bill

    Hi Bill,
    This could potentially be an issue with jQuery Moble's AJAX navigation. By default, jQuery Mobile loads pages via AJAX to allow for smooth page transitions. This means that instead of doing a full page load for the next page, jQuery Mobile loads that page into the DOM of the current page and then replaces the content via JavaSript.
    Since APEX 4.2 is using jQuery Mobile for the mobile templates, the same is true of APEX pages that you navigate to from a mobile page, as well as links to other content, such as your file download. One way to circumvent this would be to defined you links as: "javascript:location.href=([your link]);" instead of just a plain link. Depending on your specific implementation, there are also other jQuery Mobile settings that would allow for having link targets not be loaded via AJAX. Take a look at rel="external" and data-ajax="false" in the jQuery Mobile documentation, and see what might apply to your scenario:
    http://jquerymobile.com/test/docs/pages/page-links.html
    Regards,
    Marc

  • Download files & header/footer problem

    Hello
    I'm having two problems on my application.
    I've created a table to save the files from a file browser following the tutorial.
    Everything is working fine except the download option. When I try to download the file I always get this message: "Forbidden
    The requested operation is not allowed".
    I've created the download_my_file procedure, executed the grant and changed the download link to use the new procedure.
    My other problem is with reports, I'm trying to make a template to my print reports, but header and footer aren't saved. DO I need to make something different for I can use header and footer?
    Edited by: Ownr on 21/Nov/2008 13:14

    Hi,
    Regarding your first question: Are you using OracleXE oder 11g with the PL/SQL Embedded Gateway (no Apache)?
    Then here might be a solution:
    http://daust.blogspot.com/2006/04/xe-calling-stored-procedures.html
    Best regards
    -Carsten

  • Security issues to consider with download links

    Hello,
    I'm following the "How to Upload and Download Files in an Application" section of the Advanced Tutorial for APEX. I would like to integrate the security portion mentioned at the end ,however, i'm not sure how to integrate it into the download_my_file procedure. I have tried to include a block of code into the procedure so that it runs first but I get errors.
    Here is the Procedure code:
    create or replace PROCEDURE download_my_file(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM file_subjects
    WHERE id = p_file;
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    htp.p('Content-length: ' || v_length);
    htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr
    (v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
    owa_util.http_header_close;
    wpg_docload.download_file( Lob_loc );
    end download_my_file;
    Here is the "Security" code:
    APEX_APPLICATION.G_FLOW_ID := 100;
    IF NOT wwv_flow_custom_auth_std.is_session_valid then
    htp.p('Unauthorized access - file will not be retrieved.');
    RETURN;
    END IF;
    I have tried to put the security code in a block in front the the "download_my_file" procedure but it did not work for me. I need to know how to integrate the two so that it works. I would greatly appreciate the help.
    Thanks
    LEH

    Hi,
    Have you tried something like:
    create or replace PROCEDURE download_my_file(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    APEX_APPLICATION.G_FLOW_ID := 100;
    IF wwv_flow_custom_auth_std.is_session_valid then
      SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
      INTO v_mime,lob_loc,v_file_name,v_length
      FROM file_subjects
      WHERE id = p_file;
      owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
      htp.p('Content-length: ' || v_length);
      htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr
      (v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
      owa_util.http_header_close;
      wpg_docload.download_file( Lob_loc );
    ELSE
      htp.p('Unauthorized access - file will not be retrieved.');
    END IF;
    end download_my_file;Andy

  • Upload and Download file from filesystem

    Hi all,
    I have followed the instruction from the following thread
    Store \ Retrieve files from file system
    I managed to get it working for the uploading. I can see the file in my file system.
    But my download process is not working. I wasn't really clear how to call the download procedure via on demand process, so I am doing it this way:
    1. create page 0
    2. create application item called FILESEQ ( to store the file id to be downloaded)
    2. create application processs download_file which call the "download_my_file" procedure
        condition is "when request = "download_document"
    3. on the page where i have the file list, on click on the file name I set
        * target to Page 0
        * request = "download_document"
        * set application item FILESEQ = #FILESEQ#
    {code}
    So I did all that but I am getting
    {code}
    Firefox can't find the file at http://las-apexdev/pls/apex/dev/f?p=145:0:4030629153244876:DOWNLOAD_MY_FILE:NO::FILESEQ:2011080007
    {code}
    To make sure that my application process and method to call that process work.
    I changed the "download_my_file" procedure to grab the file from the table (just for troubleshooting purpose I store the file both in table and filesystem) and I was able to get the file.
    So it's really a road block for me now. I hope someone can help me with this one.
    Cheers,
    Joel
    This is the download procedure
    {code}
    CREATE OR REPLACE PROCEDURE download_my_file (p_file VARCHAR2)
    IS
       v_length      NUMBER;
       v_file_name   VARCHAR2 (2000);
       Lob_loc       BFILE;
    BEGIN
       SELECT file_name
         INTO v_file_name
         FROM attachment
        WHERE Fileseq = p_file;
       Lob_loc := BFILENAME ('LASITVENDORDB_FILE_DIR', v_file_name);
       v_length := DBMS_LOB.getlength (Lob_loc);
       OWA_UTIL.mime_header ('application/octet', FALSE);
       HTP.p ('Content-length: ' || v_length);
       HTP.p ('Content-Disposition: attachment; filename="' || SUBSTR (v_file_name, INSTR (v_file_name, '/') + 1) || '"');
       OWA_UTIL.http_header_close;
       WPG_DOCLOAD.download_file (Lob_loc);
    END;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    DAD user need have read privilege to folder. If you use EPG then ANONYMOUS is DAD user.
    If you use OHS or Apex Listener then DAD user is APEX_PUBLIC_USER (usually)
    Regards,
    Jari

  • Count the number of mail views

    Hi All,
    I send an email which has following html code :
    <pre >
    <div xmlns="http://www.w3.org/1999/xhtml" class="blank-region">
    <b> <img width="100" height="100" src="
    https://xyz.com/pls/apex/Test.WCE_KM.download_my_files?p_id=22539227238556772"/>
    </b>
    This is the email text 1 <b> 1</b> times.
    This is the email text 2 <b>0</b> people.
    <div class="clear"/>
    </div>
    </pre>
    The code is inserted into outlook or thunderbird as a mail text .
    I would like to know how many people have opened that email. The idea is count the number of times the image is loaded in the mail box. and in the "download_my_files" procedure I write an insert statement to insert one count each time the image is loaded.
    Since it is inserted as a html text, I am not able to capture the image download hits or how many times people have opened the mail.
    Any idea how to achieve this ?
    Regards,
    Archana

    Thanks AndyH for the reply. I am using "download_my_files" just to record the number of accesses for the files for later processing on the database server.
    The mail body has few images which are stored in the table as a blob type. Those images are uploaded from the file browse button in the apex application.
    I use "download_my_files" to record the number of accesses for the image files. Who views those image files in their mail when they open the mail- download_my_files process should be executed to show the file in the mail and ideally it should enter a hit in my hits table.
    I use the following process to view a file in the browser as well in the mail body . I pass the file id as a parameter
    CREATE OR REPLACE PROCEDURE download_my_files(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM oehr_file_subject
    WHERE id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    INSERT INTO mail_hits(hitcount,viewdate) VALUES (1,SYSDATE);
    end download_my_files;
    But when I add the html code as a text which includes image file links and some text, as I mentioned in my first post-- it is pasted as a content on the mail body. It doesn't contain the link to the file in the apex server.
    Is there any solution to track the hits in this method or You suggest any other method to calculate the mail count who has opened the email which has few images.
    Regards,
    Archana

  • PROCEDURE download_my_file with .docx files

    I am using the procedure download_my_file from the Application Express Advanced Tutorials site:
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/up_dn_files.htm
    If I save a file with a .docx extension, and then try to open the file using the procedure, the file type is not recognized. The file extension is also not displayed with the name. Is this caused by having a 4 digit file extension rather than the standard 3 digit extension?
    Thanks in advance for your help,
    Glen

    Hi,
    Have a look at: Uploading files Mime Type not correct for Office 2007 default extensions. I don't have access to a server to be able to check, but I have seen before that there are files on the server that you need to update to recognise new mimetypes.
    Here's a list of the mimetypes for Office 2007: [http://wdg.uncc.edu/Microsoft_Office_2007_MIME_Types_for_Apache_and_IIS]
    Andy

  • Downlad File procedure - inserting records in a table

    This procedure, I am using to count the downloads from my application, in my workspace on apex.oracle.com, used to work until couple of days ago:
    CREATE OR REPLACE PROCEDURE "DOWNLOAD_MY_FILE" (p_file IN NUMBER)
    AS
       v_mime        VARCHAR2 (48);
       v_length      NUMBER;
       v_file_name   VARCHAR2 (2000);
       lob_loc       BLOB;
       v_subject     VARCHAR2 (50);
    BEGIN
       SELECT mime_type, blob_content, NAME, DBMS_LOB.getlength (blob_content),
              subject
         INTO v_mime, lob_loc, v_file_name, v_length,
              v_subject
         FROM my_file_table
        WHERE ID = p_file;
       IF LOWER (v_subject) IN
                 ('xml chart package', 'export to excel - xe', 'export to excel')
       THEN
          INSERT INTO dkubicek.log_download_id
               VALUES (p_file, SYSDATE, v_subject, NULL);
       END IF;
       OWA_UTIL.mime_header (NVL (v_mime, 'application/octet'), FALSE);
       HTP.p ('Content-length: ' || v_length);
       HTP.p (   'Content-Disposition:  attachment; filename="'
              || REPLACE (REPLACE (SUBSTR (v_file_name,
                                           INSTR (v_file_name, '/') + 1
                                   CHR (10),
                                   NULL
                          CHR (13),
                          NULL
              || '"'
       OWA_UTIL.http_header_close;
       WPG_DOCLOAD.download_file (lob_loc);
    END download_my_file;Now, I have to exclude:
       IF LOWER (v_subject) IN
                 ('xml chart package', 'export to excel - xe', 'export to excel')
       THEN
          INSERT INTO dkubicek.log_download_id
               VALUES (p_file, SYSDATE, v_subject, NULL);
       END IF;in order to get it working again. Otherwise, I keep getting
    the 404 - Page not found error. Did something change? A new feature?
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

    Thanks for the hint. I just saw that the tablespace is full and had to request some storage.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for

  • How do I make phone vibrate longer for a text message?

    I have an iphone 4s and I am wondering how I can set the vibrate longer for a text message.  I have it turned on.  I have set the vibrate to "Rapid". I vibrates long for a phone call, but I want it to vibrate longer than a short burst, which is repea

  • Ok. This is starting to get annoying.

    I have had my silver 80gb iPod Classic for quite awhile now and I have LOVED it. It's treated me extremely well. I've never once had a problem getting music onto it, editing anything on it, absolutely no problems what-so-ever. Until recently. I plugg

  • MacBook is 10.10.2 upgrade, iPod no longer appears in iTunes.

    Hi, since upgrading my Macbook pro to latest software OS X Yosemite 10.10.2 my iPod classic is no longer recognised in iTunes. It shows as connected on iPod and can be found in disc utility and as an external source but nothing at all in iTunes. Have

  • How do I change title/footer messages in a template?

    I am redacting a magazine template Indesign. Pages already have titles and footers. How do I change TITLE message and add a footer message?  I can't do so by just clicking on the text in the footer or header.

  • Downloading a .csv file as excel sheet

    hi, does anyone know how to ensure that when downloading a csv file, it will be opened with excel only. The browser is downloading it as a text file and not excel. how can this be prevented. please let me know if you have any ideas since i've been po