Show "Save As" dialog

Hello everyone,

I hope somebody could help me out…
i need to show the “save as” dialog and save a file(could be a PDF, Excel, HTML)…
i was able to show the dialog already but it will only save the web page…


is there any way I could specify the file using the above command?
or is there another way of doing this?

please help me…any suggestions will be greatly appreciated…

many thanks in advance…Show “Save As” dialog

You cant use JavaScript do do this and be sure it will work. You have to use HTTP headers and send the actual document (PDF, Excel etc.) with Content-Disposition: Attachment. There is plenty of information upon this subject and there are plenty of inconsistent behaviours between different browsers on this subject. SO you better do your homework :slight_smile:


Added the the text in bold.

hey andrin thanks for the quick reply…and thanks for that info…will do some research on Content-Disposition: Attachment…

many thanks… :blush:

hello again,
i already have tried using Content-Disposition: Attachment…

response.setHeader("Content-Disposition", "attachment; filename='C:\\\	emp.txt\\"");

but problem is once the page is loaded the save as dialog pops out immediately…what i need now is for me to show the save as dialog once a link is clicked.

can you give me some hint on how to go about this…plz? jst a hint? (btw am using struts framewrk here)… :blush:

You have to implement a asp (or are you using .NET?) that read the file to be downloaded and that issues response with correct HTTP headers. So… Say you have a page with links:

<a href="foo.txt">foo.txt</a><br />
<a href="bar.txt">bar.txt</a>

You can conf. your webserver to always response with Content-Disposition: Attachment for files with speified file suffix (.xls, .txt, .pdf etc.). This is the best way if you know that you ALWAYS want to issue a ‘save as’-dialog for these kind of files. There are plenty of tutorials and examples on how to do this for Apache and other web servers. As I dont do IIS I cant point you to a page but you can always speak with the vendor for that software.

If you don´t want to issue this kind of response ALWAYS you have to use a read-n-respone-page. Then you have to do something like this:

<a href="/download/?file=foo.txt">foo.txt</a><br />
<a href="/download/?file=bar.txt">bar.txt</a>

the application under /download/ must then read the file, set the correct HTTP headers and then make the response. This way you issue the ‘save as’-dialog on click.


Maybe move this thread to ‘whatever technology’ n0vembr is using?

hello again,
many many thanks for your replies… indeed i got it running by using “Content-Disposition”… btw i am using JSP. just needed to add another jsp page that will implement the downloading part. :slight_smile:

thanks again for the enlightenment…greatly appreciated. :blush: