简体   繁体   中英

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.

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.

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.

从PhoneGap 2.9版开始,可以将base64存储到具有给定FileWriter的文件夹中,但仅适用于Android和iOS。

Another approach

  1. You can directly assign base64 string as src attribute to an image tag.
  2. Use canvas and write image into it.
  3. download canvas as image.

See below links for your help:- Image 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.

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.

In JavaScript you cannot have the direct access to the filesystem. Refer this link . However if you can use the node.js you can able to save the file, Refer this link . PhoneGap command-line interface and node.js library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM