• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying the File Download dialog box

 
Siphiwe Madi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to allow users of the site to be able to download a file (e.g Calendar Image file) when they click the Download link.

I have the url and have put it inside the tag
<a href="<%=URL%>">Download</a>, but this is opening the image in the window.

I want it to open the File Download dialog box with the options to Save or Open the File.

I'm doing this in a jsp within a portlet.
Your help will be greatly appreciated.

Kind Regards,
Siphiwe Madi
[ July 23, 2008: Message edited by: Bear Bibeault ]
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to display that dialog box
But I think this is because the browser knows of the image file. If you put something else in the href like say a .xyz file then the browser will show the dialog you are talking of.

Same thing applies to PDF documents when you have a reader in place, the browser opens the file opens it or displays the dialog you are talking of.


Hope this helps
 
mohan kumar r
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
portal framework you are using may stop/override download popup window. If i am not wrong every window is a part of framework once you integrate your application with framework.I have faced the same problem once and i have a provision to specify not to dispaly pop up window in portal framework as below and that's solves the problem.
<a href="url?...&pCpslayout=false">payload</a>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't force browsers to do anything but, the best way to convice one to prompt the user with a Save/Open dialog box is to set the content type to something that the browser wouldn't have an association for.

When you do this, if you also set the Content-Disposition header, you can suggest that the browser use a particular file name when saving and (if the contentType is known, suggest that the browser not try to open the associated application inline but instead prompt the user with the save/open dialog box.

In our JSP FAQ under JspAndExcel there is an example that sets both the Content-Type and the Content-Disposition headers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic