Problems with downloading file from database!
538097Dec 26 2006 — edited Jan 4 2007I have a table with my files:
NAME VARCHAR2(256)
LAST_UPDATED DATE
MIME_TYPE VARCHAR2(128)
DOC_SIZE NUMBER
DAD_CHARSET VARCHAR2(128)
CONTENT_TYPE VARCHAR2(128)
CONTENT LONG RAW
BLOB_CONTENT BLOB
ID NUMBER
I have a procedure which download file for it's ID:
procedure DownloadFile(id number)
is
v_mime VARCHAR2 (48);
v_length NUMBER;
v_file_name VARCHAR2 (2000);
lob_loc BLOB;
i integer;
BEGIN
i:=id;
SELECT d.mime_type, d.blob_content, d.NAME, DBMS_LOB.getlength(d.blob_content)
INTO v_mime, lob_loc, v_file_name, v_length
FROM documents d, mydocs m
WHERE d.id=m.doc_id
and m.id=i;
--
-- 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);
end;
And when I press Download button, it open the file content in browser.
But I need save dialog, for saving the file in the clien machine.
How to solve this problem?
Regards,
Kostya!
Message was edited by:
Kostya