如何使用Phonegap将Image对象保存到Android文件中? [英] How to save an Image object into a file in Android with Phonegap?
问题描述
这就是问题,我在应用程序中生成了PNG图像,并使用JavaScript获得了Image对象,就像这样……
Here's the thing, I generate a PNG image in the application and I get an Image object with JavaScript, something like this...
var img = new Image();
img.src = 'data:image/png;base64,' + base64Img;
我想将该图像保存到内部存储中。是否有插件或可以执行此操作的方法?
I want to save that image to the internal storage. Is there a plugin or a way I can do this?
推荐答案
根据此问题:
这是文件下载任何人都可以使用的代码。您只有三个参数可以使用,例如-
This is file download code which can be used by anyone. You just have three parameters to use this like-
1) URL
2)您要在SD卡中创建的文件夹名称
2) Folder name which you want to create in your Sdcard
3)文件名(您可以输入任意文件名)
3) File name (You can give any name to file)
使用此代码可以下载所有类型的文件。您可以将其用作.js
,它也可以在 IOS
上使用。
All types of file can download by using this code. you can use this as .js
And this works on IOS
also.
-
第一步检查参数不匹配,并检查网络连接(如果有可用的呼叫下载功能)
First step check parameters mismatch and checking network connection if available call download function
第二步获得写许可权和文件夹创建
Second step to get Write permission and Folder Creation
也请检查此链接
这篇关于如何使用Phonegap将Image对象保存到Android文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!