You need to sign in to do that
Don't have an account?

Problem with download attachments
Hi
please help me to solve this below issue
i have some atachments that i have to download, its working fine but i am not able to download .txt files and Images, instead of downloading it displaying only, please help
controller
public List<String> GetSelectedAttachments() { attLinks.clear(); if(selectedAttachments.size()>0) { integer j = selectedAttachments.size(); String strURL; for(integer i=0; i<j; i++) { strURL= 'https://' + ApexPages.currentPage().getHeaders().get('Host') + '/servlet/servlet.FileDownload?file=' + selectedAttachments[i].Id; //strURL = '/servlet/servlet.FileDownload?file='+selectedAttachments[i].Id; attLinks.add(strURL); System.debug('$$$$$$$$$'+attLinks); } System.debug('&&&&&&&&&&'+attLinks.size()); return attLinks; } else { return null; } }
Visualforce page
<apex:outputPanel id="testin" rendered="{!b}"> <script> var s='{!SelectedAttachments}'; var myCars=new Array(); var ss=s.substr(1, s.length-2); myCars=ss.split(","); for(var i=0; i< myCars.length; i++) { window.open(myCars[i]); } </script> </apex:outputpanel>
Thank you
Unfortunately it doesn't seem to be possible to do that without control over the headers that the web server sends with the file. Here are some details:
http://stackoverflow.com/q/338616/266392
I tried to find some more information on the FileDownload servlet, to see if it accepted additional parameters to force a download, but I can't find any documentation that specifies parameters other than "file=".