[OpenLayers-Users] How to force browser to download a file with a OpenLayers request response

William Hudspeth bhudspeth at edac.unm.edu
Thu Jul 31 14:20:54 PDT 2014


Thank you both for your suggestions...I will work on this over the 
weekend and post when I have succeeded...


On 07/31/2014 03:09 PM, Phil Scadden wrote:
> I've handled this kind of thing by creating a hidden iframe and 
> pointed source to the file - it then asks where to send.
>         <iframe id="downloadFrame" style="display:none"></iframe> in html
>
> This in the code:
>                                     var ifrm = 
> document.getElementById('downloadFrame');
>                                     ifrm.src = 
> '../lib/download.jsp?filename=' + filename + '&filetype=xls';
>
> The download.jsp just does;
>   response.setContentType("application/octet-stream");
> response.setHeader("Content-Disposition","attachment;filename=\"" + 
> filename + "." + filetype + "\"");
>
> and then reads the file and writes to response output stream. I guess 
> that is simple enough to do in python too.
>
>
> Notice: This email and any attachments are confidential.
> If received in error please destroy and immediately notify us.
> Do not copy or disclose the contents.
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list