I have created a custom table in the DB to handle any documents that our users want to upload for storage. The uploading and downloading of files is all done thru an APEX 4.0 application that I have built. The uploading portion of the app works great, it's just the downloading of these files that is causing problems for me.

I have created a link on the page that allows the user to download the document. I used Denis Kubicek's example to extract the blob out of the table and send it through the browser to download. It actually does download the file, but the file renders in the browser, rather than asking if the user wants to "Open" or "Save" the document to their local drives. This happens in both IE (V9.0.8) and Firefox (V18.0).

BTW, I have "Use software rendering instead of GPU rendering" turned off in IE.

Below is the code I'm using to extract the blob. What am I missing here that would cause the file to render directly in the browser, rather than prompting the user if they want to "Open" or "Save" the document?

Thanks so much,
Stan

Here is the link that calls the code to download the docs: https://xxxxxxxx/pls/apex/f?p=900:0:4003915419476346:DOWNLOADDOCUMENT:::F900_DOCUMENT_ID:1186978

- DOWNLOADDOCUMENT is an application process that looks like this:
begin

if :F900_DOCUMENT_ID is not null then
DownloadDocumentDB(:F900_DOCUMENT_ID);
end if;

-- 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 (holdRec.cntrc_eval_doc_mime_typ_txt, 'application/octet'), FALSE); -- holdRec.cntrc_eval_doc_mime_typ_txt stores the MIME type

-- set the size so the browser knows how much to download
HTP.p ('Content-length: ' || holdLength);

This signals that holdRec.cntrc_eval_doc, which is a BLOB, is to be downloaded to the clients browser. And it is, except the file opens and renders IN the browser, rather than asking the user if he wants to download the file or open it. Happens in both Firefox and IE.

I know that I'm setting the values properly in my procedure, since I'm writing them them out to a test table, but it appears the values are not being emitted to the browser correctly. The content type is absolutely wrong here (this is a word document) , and the Content-disposition parameter is not even being included! That's curious...