Results 1 to 2 of 2

Thread: Download an image using iframe

  1. #1

    Default Download an image using iframe

    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:

    Code:
    Ext.Ajax.request({
                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',
                        id:'graphicsDownloadIframe',
                        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.

    Code:
    {
        success: "true",
        fileName: "data/Chrysanthemum.jpg"
    }
    I am using static response. Is there other way to test my code?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    This has nothing to do with Ext JS, you need to learn how to do this with your server and headers.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •