View Full Version : Download an image using iframe

Supriya Kale
16 Feb 2013, 9:38 PM
Hi All,

I want to download an 'image' file. I am using Ext-js 4.1.0. I am using iframe but it doesn't seem to work for the files other than 'zip' file, may be I am missing some property in 'iframe'. The control goes to 'success' call back all the time but nothing seems to happen when I am returning 'image' file path.
Please find my code below:

url : 'data/download_.json,
success: function (response, opt) {
result = Ext.decode(response.responseText);
try {Ext.destroy(Ext.get('graphicsDownloadIframe'));}catch(e) {}
Ext.core.DomHelper.append(document.body, {
tag: 'iframe',
css: 'display:none;visibility:hidden;height:0px;',
src: result.fileName,
frameBorder: 0,
width: 0,
height: 0
failure: function(){
console.log('on failure....');


My sample json.

success: "true",
fileName: "data/Chrysanthemum.jpg"

I am using static response. Is there other way to test my code?

19 Feb 2013, 1:44 PM
This has nothing to do with Ext JS, you need to learn how to do this with your server and headers.