[OpenLayers-Users] How to force browser to download a file with a OpenLayers request response
Phil Scadden
p.scadden at gns.cri.nz
Thu Jul 31 14:09:59 PDT 2014
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.
More information about the Users
mailing list