4

I have an image which I am displaying with the help of image view using Sencha Architect 2. I am able to get a tap event on the image. But I don't know how to save the image to phone when the image is tapped. I did a Google search for this but could not find the proper documentation or example.

Can anyone help me please.

Here is the code I am trying

tap: function(img, e, options) {
        var overlay = Ext.Viewport.add({
            xtype: 'panel',
            modal : true,
            hideOnMaskTap : true,
            hidden : true,
            width : 100,
            height: 40,
            items :
            [
               {
                 xtype:'button',
                 text:'Download'
               }
            ],
        });
        overlay.showBy(img);
    }

When I click on Download button the image should get saved to SD card (phone memory) or local hard drive.

can some one help me ?

Thanks.

Sukane
  • 2,632
  • 3
  • 18
  • 19
  • 1
    [this](http://stackoverflow.com/questions/13929838/is-content-disposition-attachment-blocked-from-xmlhttprequest) and [this](http://stackoverflow.com/questions/2064882/what-are-techniques-to-get-around-the-ie-file-download-security-rules/2064957#2064957) might be helpful. – SachinGutte Apr 02 '13 at 13:17
  • How can I get the image name which is tapped. The code I am trying is tap: function(img, e, options){ Ext.Msg.alert('You clicked the image' + img);} But I am not getting the image name instead I am getting a message 'You clicked the image Object' Can you help. – Sukane Apr 10 '13 at 11:45
  • image name or image src? – SachinGutte Apr 11 '13 at 05:00
  • is there any method which will give me image name ? – Sukane Apr 12 '13 at 06:00
  • not sure what do you mean by image name. Image has src that is needed to download image. But image name is unknown to me. – SachinGutte Apr 12 '13 at 17:49
  • @phobos: How will I get Image src ? Can you please share some code. I mentioned above I want to save/download image when tap event is fired. – Sukane Apr 15 '13 at 04:34

1 Answers1

0

To get the image name:

I am guessing that you are adding the image with the xtype img? If so image src is img.src

Otherwise you will need to add the following command to see what the object contains.

console.dir(img);

Save the image:

You will be able to save the image to localstorage if the source is base64. JavaScript will not write to SD Card or alike. Other than that you can cache the image.

If you are using PhoneGap this will be possible.

Dinkheller
  • 4,631
  • 5
  • 39
  • 67