Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How To Display An Uploaded File

EEGFeb 2 2014 — edited Feb 5 2014

Hi.

I am using Apex 4.2.1 with Oracle 11gR2 and mod_plsql.

I've created a form in which users upload various file types (.txt, image types, .doc, etc.).  The Apex "File Browse" item automatically uploads files into table WWV_FLOW_FILES.

Then on a separate page, a report displays a link created with: HTF.ANCHOR('P?N=' || TO_CHAR(ID), FILENAME) AS FILENAME

Clicking this link causes the browser to prompt to either "open" the file in a separate browser window or save the file to the operating system.

This all works fine.

The problem is that the uploaded files are being saved to WWV_FLOW_FILES.  With the next Apex upgrade, this table will be truncated and  my customers will lose their files.

And so, I created a custom table called UPLOAD_DOCS which contains all the columns in WWV_FLOW_FILES.  When users upload a file I just copy the uploaded file (including mime_type, length, blob, created_date, etc.) from WWV_FLOW_FILES and then immediately delete this file from WWV_FLOW_FILES.

I then created a new page containing a Dynamic PLSQL region in which I run a PLSQL procedure which, in turn, calls WPG_DOCLOAD.

Back in my report, I changed my FILENAME link to simply call this new page, passing it the ID from my UPLOAD_DOCS table.  This ID is just the ID copied from WWV_FLOW_FILES.  This ID is then used within my PLSQL procedure to retrieve the items used by WPG_DOCLOAD such as the mime_type, the blob itself, the length, etc., all of these just copied from the WWV_FLOW_FILES table.

Doing all this I thought would just display the uploaded file in a browser window just as was being done using the "P?N" syntax above.

Unfortunately, only .txt and image type files are being displayed.  Any type other than these (.doc, .pdf, .xml, etc.) displays just binary gibberish.  And
, yes, I did grant EXECUTE to PUBLIC on my PLSQL procedure.

Questions:

1) How may I display any file type using WPG_DOCLOAD?  I suspect my issue here is the mime_type that this procedure is recognizing.  I *thought* it would recognize any type.

2) Should I be using something other than WPG_DOCLOAD?  Would anyone have an example I could follow?

3) I am also trying to display the uploaded file in a popup window having a "CLOSE" button that users would just click to automatically close the window.  Can this be done?  The above "P?N" link displays files in a separate browser.  It's sometimes confusing because users are afraid that if they click the "X" icon at the far top right corner they may un-intentionally close their main Apex application rather than just the browser showing their uploaded file.  And so, displaying this file in a smaller popup with a "CLOSE" button is more intuitive.  But I'm not sure how to do this with these uploaded files.

Thank you for nay help on these.

Elie

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 5 2014
Added on Feb 2 2014
4 comments
3,289 views