问题
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