Skip to content Skip to sidebar Skip to footer

How To Create A Base64 File From Nothing?

I want to be able to create base64 files (images, sounds, video) without any previous models. For example, if I want to create a base64 64px*64px red image, how can I do this witho

Solution 1:

Try

function createFile(_data) {
  var _data = ["<!doctype html>", 
        "<imgstyle=width:64px;height:64px;"
        + "background-color:red;display:block; />"];
  var data = window.btoa(_data.join("").toString());
  var file = "data:text/html;base64," + data;
  return file
};
createFile();

jsfiddle http://jsfiddle.net/guest271314/6GPju/

see also http://www.w3.org/TR/FileAPI/ , https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa

Post a Comment for "How To Create A Base64 File From Nothing?"