How do i force the browsere to ask for save as dialog box?

Discussions

Web tier: servlets, JSP, Web frameworks: How do i force the browsere to ask for save as dialog box?

  1. Hi,
    Satish here. If i click a link in a html page, it should ask for save as dialog box as in (Hot)mail attachments. I feel the response headers has to be manipulated in such a way that the browser does not understand.
    COuld someone please help me.....
    Regards,
    Satish
  2. Satish, I think the short answer to your question is: JavaScript. You'd want to use JavaScript in your main window to generate a popup with the appropriate save yes/no dialog. Pressing the 'yes' button in your dialog would save and close; pressing 'no' would just close.
  3. Satish,

    Try setting the Content-Disposition in the HTTP header of your response.

    e.g.

    Content-Disposition: attachment; filename="suggestedName.ext"

    Most browsers will interpret this header by popping up a save as dialog box. Just to be sure, you might also want to set the Content-Type header to application/octet-stream or to some other generic type that the browser doesn't know how to handle.

    Andy