PROCEDURE download_my_file(p_file in in varchar2) AS v_mime VARCHAR2(48); v_length NUMBER(10); v_file_name VARCHAR2(2000); Lob_loc BLOB; BEGIN for c1 in (select filename, mime_type, lob_contents from file_upload where kb_id = p_file; loop v_file_name := c1.filename; lob_loc := c1.lob_contents; v_mime := c1.mime_type; v_length := dbms_lob.getlength(lob_loc); end loop; owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE ); 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(v_file_name,chr(10),null),chr(13),null)|| '"'); -- close the headers owa_util.http_header_close; -- download the BLOB wpg_docload.download_file( Lob_loc ); end download_my_file;