Convert binary data to base64 with javascript

前端 未结 4 992
遥遥无期
遥遥无期 2020-11-27 07:54

HTML5 enable you to store data locally which I think it is great. For example here is how you can use it:

        var store = window.localStorage;
        st         


        
4条回答
  •  [愿得一人]
    2020-11-27 07:58

    Use a FileReader to encode your image as a data URL:

    jQuery.ajax({...})
    .done(function (r) {
      var reader = new FileReader(
      reader.onload = (function(self) {
        return function(e) {
          document.getElementById("img").src = e.target.result;
        }
      })(this);
      reader.readAsDataURL(new Blob([r]));
    });
    

提交回复
热议问题