your code looks OK, so maybe there is just your browser setting. What browser do you use?
Also try to change your mime header from 'application/octet-stream' to 'text/plain' and page processing should be stopped after the download, so add
after the download_file statement.
I'm using the latest versions of Google Chrom and Mozilla Firefox.
I did not indicate this in the message, but of course I added the
instruction to the code.
Trying to change 'application/octet-stream' to 'text/plain' does not bring success. The page is given to the browser as "text/html", which raises the problem of inline displaying the contents of the file on the page.
What settings for browsers can I change? Browser settings by default. Files from Internet sites are downloaded normally.
I forgot to add that Tomcat 8 + ords 3.0.9 is used when working with apex.
Unfortunately I have no idea what's wrong with your setup... I modified a little bit a packaged application "Sample Upload and Download" to demonstrate that it works. Please, login to my workspace on https://apex.oracle.com/pls/apex/
application: Application 99699 - Sample File Upload and Download
and click the Files menu.There is a slightly modified Interactive report (added the last column - redirect to the page 1000 that downloads the file in a before header process). The code that should download any file as an attachment:
declare l_file_blob blob; l_file_name eba_demo_files.filename%type; l_file_mimetype eba_demo_files.file_mimetype%type; begin select file_blob , file_mimetype , filename into l_file_blob , l_file_mimetype , l_file_name from eba_demo_files where id = :p1000_file_id; owa_util.mime_header( l_file_mimetype , false ); htp.p('Content-Disposition: attachment; filename="' || l_file_name ||'"'); htp.p('Content-length: ' || dbms_lob.getlength( l_file_blob )); owa_util.http_header_close; wpg_docload.download_file( l_file_blob ); -- Stop page processing apex_application.stop_apex_engine ; end;
If you still had problems downloading your file as an attachment, please, idemonstrate your problem on apex.oracle.com (if you don't have your account yet, create a new one, it's highly useful in situations like this).
Pavel_p, thanks for the response and the attempt to help. I rechecked the code, but that's right. As a result, I decided that I created a new page, I used the same code and it works normally. What is the difference with the previous page, I could not understand ...
Excuse for troubling.