Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

27
LINES

< > BotCompany Repo | #1029740 // hjs_imgUploadBase64Encoder

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2650L) is out of date.

sS hjs_imgUploadBase64Encoder() {
  ret hscript([[
    var imgConverted = false;
    
    function submitWithImageConversion(form) {
      console.log("imgConverted: " + imgConverted + ", form: " + form);
      if (imgConverted) return true;
      imgConverted = true;
      var file = $('#imgUploader')[0].files[0];
      if (file == null) return true;
      var reader = new FileReader();

      // delay form submit until reader is done
      reader.onloadend = function () {
        var b64 = reader.result.replace(/^data:.+;base64,/, '');
        $("#f_img_base64").val(b64);
        console.log("Got base64 data: " + b64.length);
        setTimeout(function() {
          $(form).submit();
        }, 1000);
      };

      reader.readAsDataURL(file);
      return false;
    }
  ]]);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1029740
Snippet name: hjs_imgUploadBase64Encoder
Eternal ID of this version: #1029740/6
Text MD5: c43fbc86ea72a38b5cdf2099c71a0eb6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-10 15:22:21
Source code size: 818 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 215 / 301
Version history: 5 change(s)
Referenced in: [show references]