[英]How to convert base64 string to image and save it on a folder
I am developing a phonegap application, in this i'm getting a base64 string from server using ajax. 我正在开发一个phonegap应用程序,为此,我正在使用ajax从服务器获取base64字符串 。
I want to save this as image into a folder in the device. 我想将此图像另存为设备中的文件夹。
I didn't find anything in javascript and jqyery that convert an base64 string to image. 我在javascript和jqyery中找不到将base64字符串转换为图像的任何内容。
We can display base64 string in image using javascript, but i want to store this image in to a folder so please can you help me to out this problem. 我们可以使用javascript在图像中显示base64字符串,但是我想将此图像存储到一个文件夹中,所以请您能帮我解决这个问题。
从PhoneGap 2.9版开始,可以将base64存储到具有给定FileWriter的文件夹中,但仅适用于Android和iOS。
Another approach 另一种方法
See below links for your help:- Image src: base64 http://code-tricks.com/convert-the-image-to-base64-data-stream/ 请参阅以下链接以获取帮助:-图像src:base64 http://code-tricks.com/convert-the-image-to-base64-data-stream/
You'd need to write a plugin to send your base64 encoded data to the native side, encode it into binary then write it using native code. 您需要编写一个插件,以将base64编码的数据发送到本机端,将其编码为二进制,然后使用本机代码编写。
Check out the plugins info at: HERE also take a look at the phonegap source code to see how we do the file writer and you can add some code to do the base64 decode before writing. 在以下位置查看插件信息: 这里还查看了phonegap源代码,以了解我们如何进行文件编写器,您可以在编写之前添加一些代码以进行base64解码。
In JavaScript you cannot have the direct access to the filesystem. 在JavaScript中,您不能直接访问文件系统。 Refer this link .
请参考此链接 。 However if you can use the node.js you can able to save the file, Refer this link .
但是,如果可以使用node.js,则可以保存文件,请参阅此链接 。 PhoneGap command-line interface and node.js library.
PhoneGap命令行界面和node.js库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.