How save image to phone memory say SD card or local hard drive when a image tap event is fired?

北城余情 提交于 2019-12-07 10:20:22

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15756690/how-save-image-to-phone-memory-say-sd-card-or-local-hard-drive-when-a-image-tap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!